Block Pornography

Automatically stops loading of page and applies blur filter to prevent user from viewing adult content.

  1. // ==UserScript==
  2. // @name Block Pornography
  3. // @namespace -
  4. // @version 2.4.0
  5. // @description Automatically stops loading of page and applies blur filter to prevent user from viewing adult content.
  6. // @author NotYou
  7. // @include *
  8. // @match *://*/*
  9. // @exclude *://greasyfork.org/*
  10. // @exclude *://sleazyfork.org/*
  11. // @run-at document-end
  12. // @license GPL-3.0-or-later
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. let list = [
  18. 'porno', 'pornografi', 'pornografie', 'pornographie', 'pornografia', 'порно', // Global
  19. 'porn', 'pornography', 'p@rn', 'p0rn', 'p*rn', // English
  20. 'pornografía', // Spanish
  21. 'pornogrāfija', // Latvian
  22. 'pornoqrafiya', // Azerbaijani
  23. 'pornografi', // Danish
  24. 'pornografio', // Esperanto
  25. 'pornograafia', // Estonian
  26. 'pornografiaa', // Finnish
  27. 'pornograpiya', // Filipino
  28. 'pornografiya', // Uzbek
  29. 'πορνογραφία', // Greek
  30. 'ngono', 'ponografia', // Swahili
  31. 'porr', // Swedish
  32. 'pornô', // Portuguese
  33. 'zolaula', // Chichewa
  34. 'ポルノ', // Japanase
  35. 'A片', '色情', // Chinese
  36. 'الإباحية', 'المواد الإباحية', // Arabic
  37. 'فحش', 'فحش نگاری', // Urdu
  38. 'โป๊', 'ภาพอนาจาร', // Thai
  39. 'पॉर्न', 'कामोद्दीपक चित्र', // Hindi
  40. 'अश्लील', 'अश्लील साहित्य', // Nepali
  41. 'порнография', // Russian
  42. 'порнографія', // Ukrainian
  43. 'порна', 'парнаграфія', // Belarusian
  44. 'порнограф', // Mongolian
  45. 'порнографија' // Serbian
  46. ]
  47.  
  48. const TITLE = '503 Service Unavailable'
  49. const DEBUG = -1
  50.  
  51. let debug = function() {}
  52.  
  53. if(DEBUG > 0) {
  54. debug = function() {
  55. return console.log.apply(this, arguments)
  56. }
  57. }
  58.  
  59. for (let i = 0; i < list.length; i++) {
  60. let word = list[i]
  61. let isAdult = containsWord(document.title, word) || containsWord(document.body.textContent, ' ' + word + ' ')
  62.  
  63. debug(word, isAdult)
  64.  
  65. if(isAdult) {
  66. return onAdult()
  67. }
  68. }
  69.  
  70. function onAdult() {
  71. let node = document.body || document.querySelector('body')
  72.  
  73. document.title = TITLE
  74. applyFilter(node)
  75. }
  76.  
  77. function applyFilter(node) {
  78. node.setAttribute('style', (node.getAttribute('style') ?? '') + 'filter: blur(30px);-webkit-filter: blur(30px);-ms-filter: blur(30px);filter: progid: DXImageTransform.Microsoft.Blur(PixelRadius=\'30\');pointer-events: none;')
  79. }
  80.  
  81. function containsWord(str, word) {
  82. return str.toLowerCase().indexOf(word) != -1
  83. }
  84. })()