隐藏Stackoverflow左下角Cookie固定弹窗

你好

当前为 2021-05-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hide stackoverflow.com privacy panel
  3. // @name:zh-CN 隐藏Stackoverflow左下角Cookie固定弹窗
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.3
  6. // @description Many websites show panel on the left down corner to ask us to accept cookies. But it will connect google API which is NOT reachable from our country,
  7. // and the panel will never disappear. This simple script will hide the panel directly without any tips!
  8. // @description:zh-CN 你好
  9. // @author Andy Cui
  10. // @match *://superuser.com/*
  11. // @match *://stackoverflow.com/*
  12. // @match *://askubuntu.com/*
  13. // @require https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.slim.min.js
  14. /* globals jQuery, $, waitForKeyElements */
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. // Your code here...
  22.  
  23.  
  24. // find the div,some conditions
  25. /*
  26. class:
  27. ps-fixed z-nav-fixed
  28.  
  29. z-index:
  30.  
  31. 5050 or other value greater than 1000 ???
  32.  
  33. p content
  34. Your privacy
  35.  
  36. Button
  37.  
  38. Accept all cookies
  39. Customize settings
  40.  
  41. */
  42.  
  43. var panels = $('.ps-fixed.z-nav-fixed')
  44. if (panels.length < 1) return;
  45.  
  46. panels.each(function () {
  47. var panel = $(this)
  48.  
  49. var zindex = panel.css('z-index')
  50. if (zindex < 1000) return;
  51.  
  52.  
  53. // !!! Hide it
  54. panel.css("display", "none")
  55. return;
  56.  
  57. /*
  58. // more conditions ???
  59. const keywords = ["Your privacy",
  60. "accept",
  61. "cookie",
  62. "cookies",
  63. ]
  64. var pArr = panel.children('p')
  65.  
  66. var matchsArr = []
  67. pArr.each(function (){
  68. var p = $(this)
  69. var text = p.text().toLowerCase()
  70. $(keywords).each(function (){
  71. debugger
  72. var aKeyword = this.toLowerCase()
  73. if (text.includes(aKeyword)) {
  74. var pair = [text, aKeyword]
  75. matchsArr.push(pair)
  76. }
  77. })
  78. })
  79. console.log(matchsArr)
  80.  
  81.  
  82. // buttons
  83.  
  84. */
  85.  
  86. })
  87. })();