Poblock

阻止显示技术网站的政治内容

  1. // ==UserScript==
  2. // @name Poblock
  3. // @name:zh-CN Poblock
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description Block Political Content in Technology Site
  7. // @description:zh-CN 阻止显示技术网站的政治内容
  8. // @author YunYouJun
  9. // @match *://*.reactjs.org/*
  10. // @match *://*.svelte.dev/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=gf.qytechs.cn
  12. // @grant none
  13. // @run-at document-start
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. /**
  18. * add CSS Style
  19. * @param {string} innerText
  20. */
  21. function addStyle(innerText) {
  22. const style = document.createElement('style')
  23. document.body.appendChild(style)
  24. style.innerText = innerText
  25. }
  26.  
  27. /**
  28. * hide class name
  29. * @param {string} className
  30. */
  31. function hideClass(className) {
  32. addStyle(`.${className} {display: none;}`)
  33. }
  34.  
  35. const siteRules = [
  36. {
  37. name: 'react',
  38. domains: ['reactjs.org'],
  39. handler: () => {
  40. const header = document.querySelectorAll('header')[0]
  41. console.log(header.children)
  42. if (header.children && header.children.length > 1) {
  43. // removeChild can not prevent render
  44. const className = header.children[0].className
  45. hideClass(className)
  46. }
  47. }
  48. },
  49. {
  50. name: 'svelte',
  51. domains: ['svelte.dev'],
  52. handler: () => {
  53. hideClass('ukr')
  54. addStyle('.nav-spot {background-image: url(/svelte-logo.svg) !important;}')
  55. }
  56. }
  57. ]
  58.  
  59. /**
  60. * 执行规则
  61. */
  62. function run() {
  63. siteRules.some(item => {
  64. item.domains.some(domain => {
  65. if (location.href.indexOf(domain) !== -1) {
  66. item.handler();
  67. return true
  68. }
  69. })
  70. })
  71. }
  72.  
  73. (function() {
  74. 'use strict';
  75.  
  76. // Your code here...
  77. run();
  78. })();

QingJ © 2025

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