4chan better image server replace

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        4chan better image server replace
// @namespace   4chan-better-img-repl
// @include     http://boards.4chan.org/*/thread/*
// @version     1
// @grant       none
// @description Use this script if images in 4chan threads won't load/open.
// ==/UserScript==

var lastUpdated;
(function repl() {
  if (lastUpdated === undefined || ThreadUpdater.lastReply != null && lastUpdated != ThreadUpdater.lastUpdated) {
    lastUpdated = ThreadUpdater.lastUpdated;
    var els = document.getElementsByTagName("a");
    for(var i = els.length-1; i >= 0; i--) {
      var el = els[i], contains = el.outerHTML.indexOf('is2.4chan') > -1;
      if (el.className == 'fileThumb' && !contains) break;
      if (contains) el.outerHTML = el.outerHTML.replace(/s2\.4cha/, '.4cd');
    }
  }
  if (!ThreadUpdater.dead) setTimeout(repl, (ThreadUpdater.timeLeft || 1) * 1000);
})();