4chan better image server replace

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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