Greasy Fork

Greasy Fork is available in English.

起点中文网去除推荐;百度去除搜索热点列表;B站去除推荐、评论;网易云去除推荐、评论;知乎去除右侧推荐;HiFiNi签到后自动跳转主页;去除必应新闻热点推荐

这个脚本的功能有:起点中文网去除推荐;百度去除搜索热点列表;B站去除推荐、评论;网易云去除推荐、评论;知乎去除右侧推荐;HiFiNi签到后自动跳转主页;去除必应新闻热点推荐

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         起点中文网去除推荐;百度去除搜索热点列表;B站去除推荐、评论;网易云去除推荐、评论;知乎去除右侧推荐;HiFiNi签到后自动跳转主页;去除必应新闻热点推荐
// @namespace    http://greasyfork.icu/zh-CN/scripts/377847
// @version      0.8.1
// @description  这个脚本的功能有:起点中文网去除推荐;百度去除搜索热点列表;B站去除推荐、评论;网易云去除推荐、评论;知乎去除右侧推荐;HiFiNi签到后自动跳转主页;去除必应新闻热点推荐
// @author       lsovaber
// @match        https://book.qidian.com/*/*
// @match        https://www.qidian.com/*
// @match        https://*.baidu.com/*
// @match        https://music.163.com/*
// @match        https://www.bilibili.com/*
// @match        https://www.zhihu.com/*
// @match        https://www.hifini.com/*
// @match        https://cn.bing.com/*
// @grant        GM_addStyle
// @run-at       document_start
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // 创建函数
    let changeElement = function (element, status) {
        if (document.getElementsByClassName(element)) {
            [...document.getElementsByClassName(element)].map(n => {
                n.style.visibility = status
            });
        }
        if (document.getElementById(element)) {
            document.getElementById(element).style.visibility = status;
        }
    };

    // 要隐藏的元素的class或id
    let elements = ["content_right", "rs_new", "s-hotsearch-wrapper","_2v051",//百度,
        "m-rctlist f-cb", "g-wrap7", "m-sglist f-cb", "right-wrap fr",
        "book-weekly-hot-rec weekly-hot-rec", "right-items-detail", "book-album-ddl jsAutoReport",//起点
        "recommend-list report-wrap-module report-scroll-module", "pop-live report-wrap-module report-scroll-module",
        "list-item reply-wrap is-top", "comment", "reco_list", "live_recommand_report",
        "cmmts j-flag", "g-sd4",//网易云,
        "TopSearch-items", "Card css-oyqdpg",//知乎
        "bottom_row widget msnpeek nomvs", "peregrine-widgets", "below_sbox", "b_context", "wd-pn" // 必应
    ];


    const observer = new MutationObserver(function (mutations) {
        mutations.forEach(mutation => {
            if (mutation.type === 'attributes') {
                elements.forEach(function (i) {
                    changeElement(i, "hidden");
                });
            }
        });
    });

    // 监听页面变化,并隐藏元素
    observer.observe(document, {
        childList: true,
        attributes: true,
        subtree: true,
        characterData: true
    });

    let url = window.location.href
    // HiFiNi签到后自动跳转主页
    if (url === "https://www.hifini.com/sg_sign.htm" &&
        document.getElementById('sign').innerText === '已签') {
        window.location.href = 'https://www.hifini.com';
        // 知乎隐藏搜索框的placeholder
    } else if (url.includes('zhihu.com')) {
        GM_addStyle("input::placeholder{opacity: 0;}");
    }
})();