IT之家屏蔽优化器

屏蔽“曝光”类新闻,一天到晚曝光个JB,老子不看。移除看不惯的一堆垃圾信息。移除辣品广告。改变显示样式,将5页内容全部显示。

目前为 2020-06-01 提交的版本。查看 最新版本

// ==UserScript==
// @name             IT之家屏蔽优化器
// @name:zh-CN  IT之家屏蔽优化器
// @description              屏蔽“曝光”类新闻,一天到晚曝光个JB,老子不看。移除看不惯的一堆垃圾信息。移除辣品广告。改变显示样式,将5页内容全部显示。
// @description:zh-CN   屏蔽“曝光”类新闻,一天到晚曝光个JB,老子不看。移除看不惯的一堆垃圾信息。移除辣品广告。改变显示样式,将5页内容全部显示。
// @version             1.0
// @icon                  https://www.ithome.com/favicon.ico
// @author              Luoht
// @match               https://*.ithome.com/*
// @grant               unsafeWindow
// @run-at              document-end
// @namespace https://gf.qytechs.cn/users/576566
// ==/UserScript==

(function () {
    let url = window.location.href;
    if (url.indexOf("ithome")==-1) {
        return false;
    }

    var element = [];
    element.push(document.querySelector(".lf"));
    element.push(document.querySelector("#side_func"));
    element.push(document.querySelector("#postcomment3"));
    element.push(document.querySelector(".adblock"));
    element.push(document.querySelector(".shareto"));
    element.push(document.querySelector(".related_post"));
    element.push(document.querySelector("#wrapper>.sidebar"));
    element.push(document.querySelectorAll('iframe')[1]);
    element.push(document.querySelector(".page_nav"));
    element.push(document.querySelector(".con_2"));
    element.push(document.querySelector("#con > div:nth-child(4)"));
    element.push(document.querySelector(".rm-modal1-body"));
    element.push(document.querySelector(".rm-modal1-bg"));

    element.forEach(function(item) {
        if(item) item.remove();
    });

    let box = document.querySelector(".new-list-1");
    box.parentElement.parentElement.setAttribute('style', 'width:1100px');
    let ct = document.querySelector(".ct");
    ct.setAttribute('style', 'width:950px');
    let list = document.querySelectorAll("div[class~='new-list'] ul li");
    let temp_list = [];

    let loadIndex = 0;
    if (list.length > 0) {
        let pingbiArray = ["曝光", "爆料", "首曝", "预热", "官宣", "渲染图", "将 发布", "海报 公布", "当当", "福包", "会员", "云主机", "红包", "天猫", "淘宝", "李国庆", "俞渝"];
        list.forEach(function(item) {
            let text = item.querySelector("a").innerText;
            let href = item.querySelector("a").getAttribute("href");
            let isPingbi = pingbiArray.some(function(pingbi) {
                if (href.indexOf("lapin") > -1) return true;
                let ss = pingbi.trim().split(/\s+/);
                let r = ss.reduce(function (pre, item) {
                    if (pre && item) {
                        return pre + ".*(" + item + ")"
                    } else if (item) {
                        return "(" + item + ")"
                    }
                }, "")
                return new RegExp(r, 'g').test(text)
            });
            if (!isPingbi) {
                item.firstElementChild.remove();
                item.lastElementChild ? item.lastElementChild.setAttribute('style', 'width:450px') : '';
                temp_list.push(item);
            };
        });

        let ulList = [];
        let hang = 5;
        let ulNum = Math.ceil(temp_list.length / hang);

        for(let i = 0; i < ulNum; i++){
            let ul = document.createElement("ul");
            ul.setAttribute('style', 'margin-right:50px;width:450px;border-bottom:1px solid #D22222;margin-bottom:20px;padding-bottom:0;');
            ulList.push(ul);
        }

        for(let i = 0; i < temp_list.length; i++){
            ulList[Math.floor(i / hang)].appendChild(temp_list[i]);
        }

        box.innerHTML = "";


        for(let i = 0; i < ulList.length; i++){
            box.appendChild(ulList[i]);
        }

    }

})();

QingJ © 2025

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