4Chan cdn change

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

  1. // ==UserScript==
  2. // @name 4Chan cdn change
  3. // @version 1
  4. // @description Improve 4chan image load performance, by replacing image links from specific servers to CDN
  5. // @author Dankirk
  6. // @namespace Dankirk/4cdn
  7. // @grant none
  8. // @include https://*.4chan.org/*
  9. // @include http://*.4chan.org/*
  10. // @include https://*.4channel.org/*
  11. // @include http://*.4channel.org/*
  12. // ==/UserScript==
  13.  
  14. var regex = /^(https?:\/\/)[^\.]+\.4chan\.org\/(.+)$/i;
  15.  
  16. document.querySelectorAll('a.fileThumb').forEach( el => {
  17. el.href = el.href.replace(regex,"$1i\.4cdn.org\/$2");
  18. });
  19.  
  20. document.querySelectorAll('.fileText a').forEach( el => {
  21. el.href = el.href.replace(regex,"$1i\.4cdn.org\/$2");
  22. });