4chan better image server replace

Use this script if images in 4chan threads won't load/open.

  1. // ==UserScript==
  2. // @name 4chan better image server replace
  3. // @namespace 4chan-better-img-repl
  4. // @include http://boards.4chan.org/*/thread/*
  5. // @version 1
  6. // @grant none
  7. // @description Use this script if images in 4chan threads won't load/open.
  8. // ==/UserScript==
  9.  
  10. var lastUpdated;
  11. (function repl() {
  12. if (lastUpdated === undefined || ThreadUpdater.lastReply != null && lastUpdated != ThreadUpdater.lastUpdated) {
  13. lastUpdated = ThreadUpdater.lastUpdated;
  14. var els = document.getElementsByTagName("a");
  15. for(var i = els.length-1; i >= 0; i--) {
  16. var el = els[i], contains = el.outerHTML.indexOf('is2.4chan') > -1;
  17. if (el.className == 'fileThumb' && !contains) break;
  18. if (contains) el.outerHTML = el.outerHTML.replace(/s2\.4cha/, '.4cd');
  19. }
  20. }
  21. if (!ThreadUpdater.dead) setTimeout(repl, (ThreadUpdater.timeLeft || 1) * 1000);
  22. })();