禁用網頁

禁止用戶打開某些網頁

  1. // ==UserScript==
  2. // @name Disable specific sites
  3. // @name:zh-CN 禁用网页
  4. // @name:zh-TW 禁用網頁
  5. // @namespace http://tampermonkey.net/
  6. // @version 0.3
  7. // @description A script to ban a user from opening some specific sites
  8. // @description:zh-CN 禁止用户打开某些网页
  9. // @description:zh-TW 禁止用戶打開某些網頁
  10. // @author You
  11. // @match *
  12. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  13. // @grant GM_registerMenuCommand
  14. // @grant GM_unregisterMenuCommand
  15. // @license MIT
  16. // @run-at document-start
  17. // ==/UserScript==
  18. (function() {
  19. 'use strict';
  20. var disableStatus = false
  21. function init(){
  22. reloadDisableStatus()
  23. stopLoadingPageIfInDisableList()
  24. }
  25. function showDisableGmBtns(){
  26. let menu = GM_registerMenuCommand("Disable This Site", ()=>{
  27. toggleDisableStatus()
  28. document.body.innerHTML = ""
  29. GM_unregisterMenuCommand(menu)
  30. })
  31. }
  32. function showEnableGmBtns(){
  33. let menu = GM_registerMenuCommand("Enable This Site", ()=>{
  34. toggleDisableStatus()
  35. GM_unregisterMenuCommand(menu)
  36. location.reload()
  37. })
  38. }
  39. /* function isInDisableList(){
  40. return localStorage.DisableSpecificSites?true:false
  41. } */
  42. function reloadDisableStatus(){
  43. disableStatus = localStorage.DisableSpecificSites=="true"?true:false
  44. }
  45. function stopLoadingPageIfInDisableList(){
  46. if(disableStatus == true){
  47. //console.log(disableStatus)
  48. //showErrorPage()
  49. // window.stop()
  50. var intv = setInterval(()=>{
  51. document.body.remove()
  52. if (document.body == void 0) clearInterval(intv)
  53. }, 10)
  54. showEnableGmBtns()
  55. }else {
  56. showDisableGmBtns()
  57. }
  58. }
  59. function toggleDisableStatus(){
  60. if(disableStatus){
  61. disableStatus = false
  62. localStorage.DisableSpecificSites = false
  63. showDisableGmBtns()
  64. }
  65. else{
  66. disableStatus = true
  67. localStorage.DisableSpecificSites = true
  68. showEnableGmBtns()
  69. }
  70. }
  71. function showErrorPage(){
  72. const HTMLcode = `
  73. <div style="text-align: center; margin-top: 30%">
  74. <svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" fill="currentColor" class="bi bi-slash-circle" viewBox="0 0 16 16">
  75. <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
  76. <path d="M11.354 4.646a.5.5 0 0 0-.708 0l-6 6a.5.5 0 0 0 .708.708l6-6a.5.5 0 0 0 0-.708z"/>
  77. </svg>
  78. <div style='margin-top: 20px; font-size: 24px;font-family: system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"'>
  79. This Webpage is disabled.
  80. </div>
  81. </div>
  82. `
  83. document.write(HTMLcode)
  84. }
  85. init()
  86. })();

QingJ © 2025

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