4chan better image server replace

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

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

// ==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);
})();