Hide stackoverflow.com privacy panel

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,

目前為 2021-06-06 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Hide stackoverflow.com privacy panel
  3. // @name:zh-CN 隐藏Stackoverflow左下角Cookie固定弹窗
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.4
  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. // @match *://serverfault.com/*
  14. // @require https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.slim.min.js
  15. /* globals jQuery, $, waitForKeyElements */
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. 'use strict';
  21.  
  22. // Your code here...
  23.  
  24.  
  25. // find the div,some conditions
  26. /*
  27. class:
  28. ps-fixed z-nav-fixed
  29.  
  30. z-index:
  31.  
  32. 5050 or other value greater than 1000 ???
  33.  
  34. p content
  35. Your privacy
  36.  
  37. Button
  38.  
  39. Accept all cookies
  40. Customize settings
  41.  
  42. */
  43.  
  44. var panels = $('.ps-fixed.z-nav-fixed')
  45. if (panels.length < 1) return;
  46.  
  47. panels.each(function () {
  48. var panel = $(this)
  49.  
  50. var zindex = panel.css('z-index')
  51. if (zindex < 1000) return;
  52.  
  53.  
  54. // !!! Hide it
  55. panel.css("display", "none")
  56. return;
  57.  
  58. /*
  59. // more conditions ???
  60. const keywords = ["Your privacy",
  61. "accept",
  62. "cookie",
  63. "cookies",
  64. ]
  65. var pArr = panel.children('p')
  66.  
  67. var matchsArr = []
  68. pArr.each(function (){
  69. var p = $(this)
  70. var text = p.text().toLowerCase()
  71. $(keywords).each(function (){
  72. debugger
  73. var aKeyword = this.toLowerCase()
  74. if (text.includes(aKeyword)) {
  75. var pair = [text, aKeyword]
  76. matchsArr.push(pair)
  77. }
  78. })
  79. })
  80. console.log(matchsArr)
  81.  
  82.  
  83. // buttons
  84.  
  85. */
  86.  
  87. })
  88. })();