Imgur No More Posts

Removes "Newest posts" and "Explore posts"

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Imgur No More Posts
// @namespace    https://gitlab.com/Dwyriel
// @version      1.1.1
// @description  Removes "Newest posts" and "Explore posts"
// @author       Dwyriel
// @license      MIT
// @match        *://*.imgur.com/*
// @grant        GM.registerMenuCommand
// @run-at       document-idle
// @homepageURL  https://gitlab.com/Dwyriel/Greasyfork-Scripts
// ==/UserScript==

(function () {
    'use strict';
    const userscriptName = "[Imgur No More Posts]";

    let mutationObs;
    
    const mutationObsStart = () => { mutationObs.observe(document.body, { attributes: true, childList: true, subtree: true }); };
    const yesNoString = (bool) => { return bool ? "Yes" : "No"; };

    const enhanceImagesKey = "INMP_enhance_images";
    const enhanceImagesMenuString = "Enhance images: ";
    let shouldEnhanceImages = false;
    const enhanceImages = () => {
        let images = document.querySelectorAll(`img[loading="lazy"]`);
        for (let img of images) 
            if (img.src.indexOf("_d.webp") != -1)
                img.src = img.src.split("_d.webp")[0] + ".png";
    }
    const menuEntry_EnhanceImagesAction = () => {
        mutationObs.disconnect();
        shouldEnhanceImages = !shouldEnhanceImages;
        localStorage.setItem(enhanceImagesKey, shouldEnhanceImages);
        if (shouldEnhanceImages)
            enhanceImages();
        GM.registerMenuCommand(enhanceImagesMenuString + yesNoString(shouldEnhanceImages), menuEntry_EnhanceImagesAction, { id: enhanceImagesKey, autoClose: false });
        mutationObsStart();
    }

    const callback = () => {
        mutationObs.disconnect();
        let infititeScroll = document.getElementsByClassName("BottomRecirc");
        for (let item of infititeScroll)
            item.parentNode.remove();
        let sidebar = document.getElementsByClassName("Gallery-Sidebar");
        for (let item of sidebar)
            item.remove();
        if (shouldEnhanceImages)
            enhanceImages();
        mutationObsStart();
    }

    try {
        let enhanceImagesStorageValue = localStorage.getItem(enhanceImagesKey);
        if (enhanceImagesStorageValue)
            shouldEnhanceImages = enhanceImagesStorageValue == "true";
    } catch {
        console.error(`${userscriptName} Couldn't read saved settings from localStorage`);
    }
    try {
        GM.registerMenuCommand(enhanceImagesMenuString + yesNoString(shouldEnhanceImages), menuEntry_EnhanceImagesAction, { id: enhanceImagesKey, autoClose: false });
    } catch (err) {
        console.error(`${userscriptName} Couldn't add GM menu entries`);
        console.error(err);
    }
    mutationObs = new MutationObserver(callback);
    mutationObsStart();
    callback();
})();