您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
简单的网页无图模式
当前为
// ==UserScript== // @name 无图模式 // @namespace // @include *://movie.douban.com // @include *://movie.douban.com/* // @version 0.1.9 // @description 简单的网页无图模式 // @author ymzhao // @namespace // ==/UserScript== ; (function() { 'use strict'; const clearedTag = '#'; // 清理图片src let clearImgs = function(source) { let notNull = 0; let elements = document.getElementsByTagName("img"); Array.prototype.forEach.call(elements, function (element) { if(element.src != clearedTag) { element.src = clearedTag; notNull++; } }); console.log('clear: source = ' + source + ', count = ' + elements.length + ', dealed = ' + notNull); } // 定时器 let interval = window.setInterval(function(){ if(!isImgsAllCleared) { clearImgs('interval'); } },200); // 清楚定时器 window.setTimeout(function(){ clearInterval(interval); },1500); // 初次清除图片 clearImgs('first'); // 新增DOM时,清除图片 document.addEventListener('DOMNodeInserted', throttle(function() { if(!isImgsAllCleared()) clearImgs('DOM Inserted'); }, 200)); /** * 新图判断 */ function isImgsAllCleared() { //console.log('check start'); let elements = document.getElementsByTagName("img"); //console.log('check is all cleared: count = ' + count); if(elements.length == 0) return true; return Array.prototype.every.call(elements, function (element) { element.src = clearedTag; }); } /** * 节流 * * @param fn {Function} 实际要执行的函数 * @param delay {Number} 执行间隔,单位是毫秒(ms) * * @return {Function} 返回一个“节流”函数 */ function throttle(fn, threshhold) { var last var timer threshhold || (threshhold = 250) return function () { var context = this var args = arguments var now = +new Date() if (last && now < last + threshhold) { clearTimeout(timer) timer = setTimeout(function () { last = now fn.apply(context, args) }, threshhold) } else { last = now fn.apply(context, args) } } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址