保持专注_keepFocused

临时屏蔽指定url,给自己一个清净(只屏蔽首页,防止摸鱼,但详情页不屏蔽,便于从搜索引擎进入查找资料)

当前为 2021-04-25 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         保持专注_keepFocused
// @namespace    http://tampermonkey.net/
// @version      2021.4.25.2222
// @description  临时屏蔽指定url,给自己一个清净(只屏蔽首页,防止摸鱼,但详情页不屏蔽,便于从搜索引擎进入查找资料)
// @author       https://github.com/find456789/
// @match        *://*/*
// @grant        none
// @license MIT
// @copyright 2019, https://greasyfork.org/zh-CN/scripts/377325-keepfocused
// ==/UserScript==




// =======================================
// =======================================
// ============ 配置文件开始 ===============
// =======================================
// =======================================

//这里是黑名单
var 黑名单 = [
    "test.com", // 只屏蔽 test.com, 不会屏蔽 www.test.com
    "www.test.com", //只屏蔽 www.test.com, 不会屏蔽 其他子域名
     "test.com/hot", // 只屏蔽 test.com/hot (test.com域名下的hot主目录)
    // 暂不支持通配符,后续可能会支持 "*.test.com", // 会屏蔽test.com和 任意子域名的test.com(如www.test.com, abc.test.com,等等)


    "zhihu.com/hot", "www.zhihu.com/hot", // 知乎hot页
    "V2ex.com", "www.V2ex.com", // v2ex 首页
    "zhihu.com", "www.zhihu.com", // 知乎首页

    "bilibili.com","www.bilibili.com",// bilibili首页
    "youtube.com","www.youtube.com",// bilibili首页

];

var 提示 = "懵逼树上懵逼果,懵逼树下你和我"; // 拦截网址后的提示文字

var 弱提示 = "来自 keepFocused on Tampermonkey的问候"; // 友情提示

// =======================================
// =======================================
// ============ 配置文件结束 ===============
// =======================================
// =======================================


// =======================================
// =======================================
// ============ 核心代码开始 ===============
// =======================================
// =======================================

(function() {
    'use strict';

    // Your code here...

    黑名单 = 黑名单.map(t => {
        t = t.toLowerCase() // 全部转换为小写,防止失误域名用了大写
        if(t.substr(t.length-1,1)=="/"){// 删除结尾的斜杠 /
            t.substring(0, t.length - 1);
        }

        return t

    });

    var url=new URL(window.location.href) // 获取当前打开的网址


    if(黑名单.indexOf(url.host) >= 0){ // 如果当前网址在黑名单, 就执行if语句内的代码
        //console.log("当前网址在黑名单< from keepFocused on Tampermonkey")

          if(url.pathname=="/"){// 当前页面是根目录,直接拉黑

                console.log("1当前网址在黑名单 < from keepFocused on Tampermonkey");
                document.body.innerHTML= "<div style=\"display: flex;justify-content: center;align-items: center;\"><h1 style=\"margin-top: 40px;font-size: 50px\">" + 提示 + "</h1></div><span style=\" font-size: small; color: #e0dbdb; \">" + 弱提示 + "<span>";

          }else{ // 如果当前页面不是网站根目录,将继续判断当前url是否被拉黑

             //  console.log("黑名单网址-当前页面不是网站根目录,< from keepFocused on Tampermonkey")

            if( 黑名单.indexOf(url.host+url.pathname) >= 0){ // 如果当前url 在黑名单
               // console.log("黑名单网址- 当前url 在黑名单< from keepFocused on Tampermonkey")


                console.log("2当前网址在黑名单 < from keepFocused on Tampermonkey");
                document.body.innerHTML= "<div style=\"display: flex;justify-content: center;align-items: center;\"><h1 style=\"margin-top: 40px;font-size: 50px\">" + 提示 + "</h1></div><span style=\" font-size: small; color: #e0dbdb; \">" + 弱提示 + "<span>";
            }

          }





       
    }


})();

// =======================================
// =======================================
// ============ 核心代码结束 ===============
// =======================================
// =======================================