Greasy Fork is available in English.

Pixiv反代链接替换

使用国内反代节点替换Pixiv日本图片节点

  1. // ==UserScript==
  2. // @name Pixiv反代链接替换
  3. // @namespace https://www.cccpserver.cf
  4. // @version 1.02
  5. // @description 使用国内反代节点替换Pixiv日本图片节点
  6. // @author HELPMEEADICE
  7. // @match *://www.pixiv.net/*
  8. // @license GPLv3
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function replacePximgLinks() {
  16. const links = document.querySelectorAll('a[href*="i.pximg.net"]');
  17. const images = document.querySelectorAll('img[src*="i.pximg.net"]');
  18.  
  19. links.forEach(link => {
  20. link.href = link.href.replace(/i\.pximg\.net/g, 'i.pixivcat.com');
  21. });
  22.  
  23. images.forEach(image => {
  24. image.src = image.src.replace(/i\.pximg\.net/g, 'i.pixivcat.com');
  25. });
  26. }
  27.  
  28. replacePximgLinks();
  29.  
  30. // Listen for changes in the DOM, in case the page uses AJAX to load content
  31. const observer = new MutationObserver(replacePximgLinks);
  32. observer.observe(document.body, { subtree: true, childList: true });
  33. })();