Remove PW images

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

  1. // ==UserScript==
  2. // @name Remove PW images
  3. // @namespace https://politicsandwar.com/nation/id=98616
  4. // @description Hide any images that you would prefer not to see on the Politics and War website
  5. // @version 0.1
  6. // @author Talus
  7. // @license GPL-3.0-or-later
  8. // @match *://*.politicsandwar.com/*
  9. // @run-at document-start
  10. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  11. // @grant GM_registerMenuCommand
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. var configId = 'blockedImgUrlsConfig'; // Configuration ID for GM_config
  20.  
  21. // Create the GM_config object
  22. var config = new GM_config({
  23. id: configId,
  24. title: 'Blocked Image URLs Configuration',
  25. fields: {
  26. blockedImgUrls: {
  27. label: 'Blocked URLs (one per line)',
  28. type: 'textarea',
  29. cols: 50,
  30. rows: 10
  31. }
  32. },
  33. events: {
  34. save: function() {
  35. var newBlockedUrls = config.get('blockedImgUrls').split('\n').map(url => url.trim());
  36. GM_setValue('blockedImgUrls', newBlockedUrls);
  37. blockImages(newBlockedUrls); // Block the images based on the updated URLs
  38. }
  39. }
  40. });
  41.  
  42. // Register a menu command to open the configuration interface
  43. GM_registerMenuCommand('Manage Blocked URLs', config.open.bind(config));
  44.  
  45. // Retrieve the blocked URLs from the user script settings
  46. var blockedImgUrls = GM_getValue('blockedImgUrls', []);
  47.  
  48. // Block the images based on the stored blocked URLs
  49. blockImages(blockedImgUrls);
  50.  
  51. // Function to block the images based on the provided URLs
  52. function blockImages(urls) {
  53. var css = urls.map(url => `img[src*="${decodeURIComponent(url)}"] { display: none !important; }`).join('\n');
  54. var style = document.createElement('style');
  55. style.textContent = css;
  56. document.head.appendChild(style);
  57. }
  58. })();