Greasy Fork

Greasy Fork is available in English.

摸鱼神器/屏蔽图片/屏蔽视频/上班划水/图片移除/视频移除

科学摸鱼必备!上班的时候无聊想摸鱼刷帖子,只想看文字不想页面显示图片和视频的时候怎么办,就是它了~

当前为 2022-01-11 提交的版本,查看 最新版本

// ==UserScript==
// @name         摸鱼神器/屏蔽图片/屏蔽视频/上班划水/图片移除/视频移除
// @namespace    
// @version      0.2
// @description  科学摸鱼必备!上班的时候无聊想摸鱼刷帖子,只想看文字不想页面显示图片和视频的时候怎么办,就是它了~
// @author       FlyArtist
// @match        *
// @icon
// @grant        none
// @include      *
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function clearMedia() {
        const srcChecker = /url\(\s*?['"]?\s*?(\S+?)\s*?["']?\s*?\)/i;
        var doc = document.querySelectorAll('*');
        for (var i = 0; i < doc.length; i++) {
            if (doc[i].nodeName === 'IMG' || doc[i].nodeName === 'SVG') {
                doc[i].setAttribute('style', 'display:none')
            }
            if (doc[i].nodeName === 'VIDEO') {
                doc[i].setAttribute('style', 'display:none')
                doc[i].parentNode.setAttribute('style', 'display:none')
            }
            let prop = window.getComputedStyle(doc[i], null)
            .getPropertyValue('background-image');
            let match = srcChecker.exec(prop);
            if (match) {
                doc[i].style.background = '';
            }
        }
    }
    
    clearMedia();
    setInterval(clearMedia, 300)
})();