Stop Scrolling Instagram

allows you to see all posts/reels from those you follow, but disables scrolling into suggested videos

目前為 2024-10-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Stop Scrolling Instagram
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  allows you to see all posts/reels from those you follow, but disables scrolling into suggested videos
// @author       Ulysses
// @match        https://www.instagram.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=instagram.com
// @grant        none
// @license      MIT

// ==/UserScript==

(function () {
    'use strict';

    // Function to find "You've completely caught up" element
    function findSuggested() {
        const suggestedChild = document.querySelector('.xh8yej3.x1ye3gou.x1gan7if.xn6708d.x1miatn0.xdt5ytf.x78zum5.x9f619.xjbqb8w.x6s0dn4');

        if (suggestedChild) {
            const suggested = suggestedChild.parentElement;
            stopAtElement(suggested);
        } else {
            enableScroll();
        }
    }

    function disableScroll(suggested) {
        // Set the margin before disabling scroll
        suggested.style.marginBottom = '900px'; //

        window.onscroll = function () {
            const elementRect = suggested.getBoundingClientRect();
            if (elementRect.bottom < window.innerHeight) {
                const bodyRect = document.body.getBoundingClientRect();
                window.scrollTo(0, elementRect.bottom - bodyRect.bottom);
            }
        };
    }

    function enableScroll() {
        window.onscroll = function () { };
    }

    function stopAtElement(element) {
        // Disable scrolling when the element is reached
        disableScroll(element);
    }

    // Use MutationObserver to monitor DOM changes
    const observer = new MutationObserver(findSuggested);
    observer.observe(document.body, { childList: true, subtree: true });

    findSuggested();
})();