pixiv ugoira fix

Makes broken Pixiv ugoira move.

  1. // ==UserScript==
  2. // @name pixiv ugoira fix
  3. // @match https://www.pixiv.net/en/artworks/*
  4. // @description Makes broken Pixiv ugoira move.
  5. // @grant unsafeWindow
  6. // @license WTFPL
  7. // @version 0.0.1.20211116235617
  8. // @namespace https://gf.qytechs.cn/users/839834
  9. // ==/UserScript==
  10.  
  11. let oldFetch = fetch;
  12.  
  13. async function persistentFetch(url) {
  14. let attemptsRemaining = 3;
  15. let response;
  16. while (attemptsRemaining--) {
  17. response = await oldFetch(url);
  18. if (response.ok) {
  19. return response;
  20. }
  21. }
  22. throw response;
  23. }
  24.  
  25. let ugoiraRegex = /^https:\/\/i\.pximg\.net\/img-zip-ugoira\/img\//;
  26. unsafeWindow.fetch = function() {
  27. if (ugoiraRegex.test(arguments[0])) {
  28. return persistentFetch(arguments[0]);
  29. }
  30. return oldFetch.apply(this, arguments);
  31. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址