4Chan cdn change

Improve 4chan image load performance, by replacing image links from specific servers to CDN

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name     4Chan cdn change
// @version  1
// @description  Improve 4chan image load performance, by replacing image links from specific servers to CDN
// @author       Dankirk
// @namespace    Dankirk/4cdn
// @grant    none
// @include        https://*.4chan.org/*
// @include        http://*.4chan.org/*
// @include        https://*.4channel.org/*
// @include        http://*.4channel.org/*
// ==/UserScript==

var regex = /^(https?:\/\/)[^\.]+\.4chan\.org\/(.+)$/i;

document.querySelectorAll('a.fileThumb').forEach( el => {
  el.href = el.href.replace(regex,"$1i\.4cdn.org\/$2");
});

document.querySelectorAll('.fileText a').forEach( el => {
  el.href = el.href.replace(regex,"$1i\.4cdn.org\/$2");
});