Remove PW images

Hide any images that you would prefer not to see on the Politics and War website

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Remove PW images
// @namespace   https://politicsandwar.com/nation/id=98616
// @description Hide any images that you would prefer not to see on the Politics and War website
// @version     0.1
// @author      Talus
// @license     GPL-3.0-or-later
// @match       *://*.politicsandwar.com/*
// @run-at      document-start
// @require     https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant       GM_registerMenuCommand
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

(function() {
    'use strict';

    var configId = 'blockedImgUrlsConfig';  // Configuration ID for GM_config

    // Create the GM_config object
    var config = new GM_config({
        id: configId,
        title: 'Blocked Image URLs Configuration',
        fields: {
            blockedImgUrls: {
                label: 'Blocked URLs (one per line)',
                type: 'textarea',
                cols: 50,
                rows: 10
            }
        },
        events: {
            save: function() {
                var newBlockedUrls = config.get('blockedImgUrls').split('\n').map(url => url.trim());
                GM_setValue('blockedImgUrls', newBlockedUrls);
                blockImages(newBlockedUrls); // Block the images based on the updated URLs
            }
        }
    });

    // Register a menu command to open the configuration interface
    GM_registerMenuCommand('Manage Blocked URLs', config.open.bind(config));

    // Retrieve the blocked URLs from the user script settings
    var blockedImgUrls = GM_getValue('blockedImgUrls', []);

    // Block the images based on the stored blocked URLs
    blockImages(blockedImgUrls);

    // Function to block the images based on the provided URLs
    function blockImages(urls) {
        var css = urls.map(url => `img[src*="${decodeURIComponent(url)}"] { display: none !important; }`).join('\n');
        var style = document.createElement('style');
        style.textContent = css;
        document.head.appendChild(style);
    }
})();