🏠 Home 

Greasy Fork is available in English.

Filter remover

用于去除网页灰色滤镜


安装此脚本?
  1. // ==UserScript==
  2. // @name Filter remover
  3. // @version 1.13
  4. // @namespace filter.404
  5. // @license GNU General Public License v3.0
  6. // @description 用于去除网页灰色滤镜
  7. // @author eduarte
  8. // @match http://*/*
  9. // @match https://*/*
  10. // @run-at document-end
  11. // ==/UserScript==
  12. //
  13. // 没有真相的致哀是对牺牲者的亵渎
  14. // 一个阻止人们自发纪念活动的政府,更没有资格搞什么「公祭日」
  15. // 我们需要这种带着反思的具体的悼念,希望将来某天,除了反思,还有追责
  16. //
  17. (function() {
  18. 'use strict';
  19. let style = document.createElement('style');
  20. style.innerHTML = "*, html, body{filter: none !important; -webkit-filter: none !important; -moz-filter: none !important; background-blend-mode: normal !important}";
  21. document.body.appendChild(style);
  22. let imgs = document.getElementsByTagName("img")
  23. for (let index in imgs) {
  24. if (imgs[index].getAttribute) {
  25. if (imgs[index].getAttribute("src") !== null) {
  26. imgs[index].setAttribute("src", imgs[index].getAttribute("src").replace("_gray", ""));
  27. }
  28. if (imgs[index].getAttribute("data-src") !== null) {
  29. imgs[index].setAttribute("data-src", imgs[index].getAttribute("data-src").replace("_gray", ""));
  30. }
  31. }
  32. }
  33. const removeFilter = () => {
  34. document.documentElement.style.setProperty('filter', 'none', 'important');
  35. document.body.style.setProperty('filter', 'none', 'important');
  36. // weibo
  37. let elems = document.querySelectorAll("[class*='gray']")
  38. for (let index in elems) {
  39. if (elems[index].getAttribute) {
  40. let classVal = elems[index].getAttribute("class");
  41. elems[index].setAttribute("class", classVal.replace("gray", ""));
  42. }
  43. }
  44. }
  45. let patience = 20;
  46. let interval;
  47. window.onload = () => {
  48. interval = setInterval(() => {
  49. if (document.querySelectorAll("[class*='gray']").length > 0) {
  50. removeFilter();
  51. patience = 20
  52. };
  53. patience--;
  54. if (patience === 0) clearInterval(interval);
  55. }, 100);
  56. }
  57. })();