Block Site

屏蔽网站,清静下来,省时间,省生命

  1. // ==UserScript==
  2. // @name Block Site
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 屏蔽网站,清静下来,省时间,省生命
  6. // @author You
  7. // @match *:*
  8. // @match *://*/*
  9. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  10. // @require https://cdn.staticfile.org/vue/2.6.14/vue.min.js
  11. // @require https://lib.baomitu.com/vue/2.6.14/vue.min.js
  12. // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
  13. // @require https://unpkg.com/element-ui/lib/index.js
  14. // @resource elementStyle https://unpkg.com/element-ui/lib/theme-chalk/index.css
  15. // @grant GM_addStyle
  16. // @grant GM_getResourceText
  17.  
  18. // @grant GM_getValue
  19. // @grant GM.getValue
  20. // @grant GM_setValue
  21. // @grant GM.setValue
  22. // @grant GM_addStyle
  23. // @grant GM_getResourceURL
  24. // @grant GM_listValues
  25. // @grant GM.getResourceUrl
  26. // @grant GM_xmlhttpRequest
  27. // @grant GM_getResourceText
  28. // @grant GM_registerMenuCommand
  29.  
  30. // ==/UserScript==
  31.  
  32. (function() {
  33. 'use strict';
  34. // 代码内部 引入bootstrap的css文件并加入html中
  35. const css = GM_getResourceText("elementStyle");
  36. GM_addStyle(css);
  37. console.log('a')
  38. if(location.href=='http://vin.kbug.cn/block.html'){
  39. let gg = GM_getValue("pre_url")
  40. $("body").html(`
  41. <div style='display: flex;justify-content: center;margin-top:calc(30vh);'>
  42. <div style="display: flex;flex-direction: column;">
  43. <div style="font-size:40px;">
  44. 敢不敢,事上练
  45. </div>
  46. <div style='margin:10px 0;font-size:20px;color: green;'>选项: 练字、编程、Emacs、英语</div>
  47. <div>正在访问URL: <a href="${gg?gg:''}">${gg?gg:''}</a></div>
  48. </div>
  49. </div>
  50. `)
  51. }
  52. if(location.href=="http://vin.kbug.cn/blocksite.html")
  53. {
  54. $("body").html(`
  55. <div id="app">
  56. <h3 >BlockSite</h3>
  57. <div >
  58. <el-input v-model="url" style="width:200px;" placeholder="请输入主域名匹配符"></el-input>
  59. <el-button @click="addUrl">添加</el-button>
  60. </div>
  61. <div>
  62. <h3>
  63. Block WebSite Pattern
  64. </h3>
  65. <p>只需要添加主域名即可, xxx.com</p>
  66. <table>
  67. <tr>
  68. <th>URL</th>
  69. <th>操作</th>
  70. </tr>
  71. <tr v-for="(u,i) in urlList" :key="i">
  72. <td >
  73. {{u}}
  74. </td>
  75. <td><el-link @click="removeUrl(u)">删除</el-link></td>
  76. </tr>
  77. </table>
  78. <p></p>
  79. </div>
  80. </div>
  81. `)
  82. document.title="BlockSite"
  83.  
  84. new Vue({
  85. el:"#app",
  86. data:{
  87. resdata:{},
  88. url:'',
  89. urlList:new Set(),
  90. },
  91. mounted(){
  92. if(GM_getValue("url")){
  93. this.urlList = new Set([...GM_getValue("url")])
  94. }else {
  95. GM_setValue("url",[])
  96. }
  97. },
  98. methods:{
  99. addUrl(){
  100. this.urlList.add(this.url)
  101. GM_setValue("url",[...this.urlList])
  102. this.urlList = new Set([...this.urlList]);
  103. this.url = ''
  104. },
  105. removeUrl(url){
  106. this.urlList.delete(url)
  107. GM_setValue("url",[...this.urlList])
  108. this.urlList = new Set([...this.urlList]);
  109. }
  110. }
  111. })
  112. }else {
  113. const urlList = GM_getValue("url");
  114. urlList.forEach(url=>{
  115. if(new RegExp(`^http.*${url}.*`).test(location.href)){
  116. location.href='http://vin.kbug.cn/block.html'
  117. GM_setValue("pre_url",location.href)
  118. console.log("已被禁止")
  119. }
  120. })
  121.  
  122. }
  123.  
  124. })();