网页锁

可以对部分网页设置网页锁保护个人隐私(尤其是那些自动登录(不可用)的网页).

  1. // ==UserScript==
  2. // @name 网页锁
  3. // @namespace https://sfkgroup.github.io/
  4. // @version 0.1
  5. // @description 可以对部分网页设置网页锁保护个人隐私(尤其是那些自动登录(不可用)的网页).
  6. // @author SFKgroup
  7. // @match *://*/*
  8. // @grant GM_log
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_registerMenuCommand
  12. // @icon https://sfkgroup.github.io/images/favicon.ico
  13. // @license LGPL
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. var lock_style = 'blur(25px) grayscale(100%)'
  18. var ban_list = GM_getValue('bans', [])
  19. var allow_list = GM_getValue('allow', [])
  20. var password = GM_getValue('pwd', '159357') // 小键盘上的X
  21.  
  22. function set_this_url() {
  23. let url = window.location.href
  24. if (ban_list.indexOf(url) >= 0) { return 0 }
  25. ban_list.push(url)
  26. GM_setValue('bans', ban_list)
  27. }
  28.  
  29. function set_all_url() {
  30. let url = window.location.origin + '*'
  31. if (ban_list.indexOf(url) >= 0) { return 0 }
  32. ban_list.push(url)
  33. GM_setValue('bans', ban_list)
  34. }
  35.  
  36. function del_this_url() {
  37. let url = window.location.href
  38. var input_key = prompt("请输入访问密钥", "");
  39. if (input_key == password) {
  40. if (ban_list.indexOf(url) >= 0) {
  41. ban_list.splice(ban_list.indexOf(url), 1)
  42. } else {
  43. if (allow_list.indexOf(url) >= 0) { return 0 }
  44. allow_list.push(url)
  45. }
  46. GM_log(ban_list, allow_list)
  47. GM_setValue('bans', ban_list)
  48. GM_setValue('allow', allow_list)
  49. } else if (input_key != null) {
  50. alert('密钥错误.')
  51. }
  52. }
  53.  
  54. function del_all_url() {
  55. let url = window.location.origin + '*'
  56. var input_key = prompt("请输入访问密钥", "");
  57. if (input_key == password) {
  58. if (ban_list.indexOf(url) >= 0) {
  59. ban_list.splice(ban_list.indexOf(url), 1)
  60. } else {
  61. if (allow_list.indexOf(url) >= 0) { return 0 }
  62. allow_list.push(url)
  63. }
  64. GM_log(ban_list, allow_list)
  65. GM_setValue('bans', ban_list)
  66. GM_setValue('allow', allow_list)
  67. } else if (input_key != null) {
  68. alert('密钥错误.')
  69. }
  70.  
  71. }
  72.  
  73. function clear_list() {
  74. var input_key = prompt("请输入访问密钥", "");
  75. if (input_key == password) {
  76. ban_list = []
  77. allow_list = []
  78. GM_setValue('bans', [])
  79. GM_setValue('allow', [])
  80.  
  81. } else if (input_key != null) {
  82. alert('密钥错误.')
  83. }
  84.  
  85. }
  86.  
  87. function set_key() {
  88. var input_key = prompt("请输入旧的访问密钥", "");
  89. if (input_key == password) {
  90. var input_key = prompt("请输入新的访问密钥", "");
  91. if (input_key != null && input_key != "") {
  92. password = input_key
  93. GM_setValue('pwd', password)
  94. } else {
  95. alert('密码不能为空.')
  96. }
  97. } else if (input_key != null) {
  98. alert('密钥错误.')
  99. }
  100. }
  101.  
  102. if (window.self === window.top) {
  103.  
  104. GM_registerMenuCommand("添加本页面", set_this_url, "s");
  105. GM_registerMenuCommand("添加本网址", set_all_url, "a");
  106. GM_registerMenuCommand("解锁本页面", del_this_url, "d");
  107. GM_registerMenuCommand("解锁本网址", del_all_url, "r");
  108. GM_registerMenuCommand("重置所有列表", clear_list, "c");
  109. GM_registerMenuCommand("设置访问密钥", set_key, "p");
  110.  
  111. var locking = false
  112.  
  113. var self_url = window.location.href
  114. for (let i = 0; i < ban_list.length; i++) {
  115. if (self_url.search(ban_list[i]) >= 0) {
  116. if (allow_list.indexOf(self_url) < 0) {
  117. document.getElementsByTagName('body')[0].style.filter = lock_style
  118. locking = true
  119. GM_log('Locked')
  120. break
  121. }
  122. }
  123. }
  124.  
  125. setTimeout(function () {
  126. if (locking) {
  127. for (let k = 0; k < 3; k++) {
  128. var input_key = prompt("请输入访问密钥", "");
  129. if (input_key == password) {
  130. document.getElementsByTagName('body')[0].style.filter = ''
  131. GM_log('UnLocked')
  132. break
  133. } else if (input_key == null) {
  134. break
  135. } else {
  136. alert('密钥错误,还有' + (2 - k) + '次机会.')
  137. }
  138. }
  139. }
  140. }, 100)
  141. }
  142.  
  143. })();

QingJ © 2025

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