├── README.md └── main.js /README.md: -------------------------------------------------------------------------------- 1 | # anti-zhihu 2 | 一款tampermonkey插件,防止您沉迷知乎无法自拔 3 | 4 | 使用了cookie。 5 | 6 | (然而我根本不会写javascript >_>) 7 | 8 | [博客](http://r64.is-programmer.com/posts/212239.html) 9 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name         fuck zhihu 3 | // @namespace    http://tampermonkey.net/ 4 | // @version      0.2 5 | // @description  Fuck zhihu! 6 | // @author       r_64 7 | // @include https://*.zhihu.com/* 8 | // @exclude https://zhuanlan.zhihu.com/* 9 | // @grant        none 10 | // ==/UserScript== 11 | (function() { 12 |     var d = new Date(); 13 |     var last_visit = document.cookie.replace(/(?:(?:^|.*;\s*)lastvisitsbwebsite\s*\=\s*([^;]*).*$)|^.*$/, "$1"); 14 |     var this_visit = d.getTime(); 15 |     document.cookie = "lastvisitsbwebsite=" + this_visit; 16 |     if (this_visit - last_visit <= 1000 * 60 * 60 * 4) { 17 |         window.location.href = 'about:blank'; 18 |         alert("为什么你老是在浏览垃圾网站"); 19 |     } else { 20 |         window.setTimeout( 21 |             function() { 22 |                 window.location.href = 'about:blank'; 23 |                 alert("不要浏览垃圾网站"); 24 |             }, 1000 * 60 * 3 25 |         ); 26 |     } 27 | })(); 28 | --------------------------------------------------------------------------------