Greasy Fork is available in English.

Block internal images hardcoded in IMG tag

Remove about: chrome: and resource: URIs from the src attribute of <img> tags.

  1. // ==UserScript==
  2. // @name Block internal images hardcoded in IMG tag
  3. // @description Remove about: chrome: and resource: URIs from the src attribute of <img> tags.
  4. // @author Jefferson "jscher2000" Scher
  5. // @namespace JeffersonScher
  6. // @copyright Copyright 2016 Jefferson Scher
  7. // @license BSD 3-clause
  8. // @include http*://*
  9. // @version 0.5.1
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // Inspiration -- also deals with <script> tags: http://userscripts-mirror.org/scripts/review/5899
  14.  
  15. // Check <img> tags for about: chrome: resource: URLs
  16. var problemimgs = document.querySelectorAll('img[src^="about:"], img[src^="chrome:"], img[src^="resource:"]');
  17. for(var i = 0; i < problemimgs.length; i++){
  18. if (problemimgs[i].hasAttribute("onload")) problemimgs[i].removeAttribute("onload");
  19. if (problemimgs[i].hasAttribute("onerror")) problemimgs[i].removeAttribute("onerror");
  20. problemimgs[i].setAttribute("alt", "BLOCKED: "+problemimgs[i].getAttribute("src"));
  21. problemimgs[i].removeAttribute("src");
  22. problemimgs[i].setAttribute("style", "border:3px double red; color:red; font-weight:bold; font-style:italic; padding: 1px 4px;");
  23. }