Remove PW images

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
    }
})();