grim's wikia content warning auto-skip

Automatically skip Wikia's content warning disclaimer

  1. // ==UserScript==
  2. // @name grim's wikia content warning auto-skip
  3. // @namespace https://gf.qytechs.cn/en/users/4367-d-p
  4. // @description Automatically skip Wikia's content warning disclaimer
  5. // @include http*.wikia.com/*
  6. // @version 1.3
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10.  
  11. // see:
  12. // http://stackoverflow.com/questions/23783774/using-a-regular-expression-in-a-greasemonkey-include
  13. // https://wiki.greasespot.net/Include_and_exclude_rules
  14. // http://stackoverflow.com/questions/12897446/greasemonkey-wait-for-page-to-load-before-executing-code-techniques
  15. // http://stackoverflow.com/questions/16873323/javascript-sleep-wait-before-continuing
  16.  
  17. // 2016-06-05 for some reason, this script isn't working anymore
  18. // it looks like the button pops up a little bit after the page is completely loading all its assets
  19.  
  20. // surround everything with the '/' to specify regex matching
  21. // regex means http or https
  22. // including any subdomain, including the domain wikia.com by itself.
  23. // subdomain can be any length with any characters, with a dot at the end. subdomain optional
  24. // * in a regex match is not a typical wildcard. I need .* because the * in regex means that any character (.) appears 0 or more times.
  25. // so in regex, 'https://example.com/xx-xx/Asset/*' means '/' appears 0 or more times
  26. // outside of regex matching, like in greasemonkey's case, * means wildcard
  27. // so 'https://example.com/xx-xx/Asset/*' means anything can appear after '/'
  28. // at .com top level domain
  29. // with anything proceeding afterwards
  30.  
  31. // So your https://example.com/xx-xx/Asset/* pattern would become:
  32. // @include /^https:\/\/example\.com\/[a-z]{2}\-[a-z]{2}\/Asset\/.*$/
  33.  
  34. // you can use either of these includes
  35. // include http*.wikia.com/*
  36. // include /^https?://(.*\.)?wikia\.com/.*$/
  37.  
  38. // <button id="ContentWarningApprove" class="approve">I understand and I wish to continue</button>
  39.  
  40. // test code to see if the document status is loading at the time of execution
  41. // at this point, the document readystate should be 'interactive'
  42. /*
  43. if ('loading' == document.readyState) {
  44. alert("This script is running at document-start time.");
  45. } else {
  46. alert("This script is running with document.readyState: " + document.readyState);
  47. }
  48. // */
  49.  
  50. // call script after the page loads
  51. // unlike blogspot, wikia needs time to load because the buttons popup afterwards
  52.  
  53.  
  54.  
  55. window.addEventListener('load', function() {
  56. // your code here
  57. // test code to see if the document status is loading at the time of execution
  58. // for some strange reason, sometimes the clicking line never executes.
  59. // if I add the alert, only then will my script click the content warning approve button
  60. // that means the alert adds some delay after the document readystate is completed
  61. //*
  62. if ('loading' == document.readyState) {
  63. //alert("This script is running at document-start time.");
  64. } else {
  65. // at this point, the document readystate should be 'completed'
  66. //alert("This script is running with document.readyState: " + document.readyState);
  67. }
  68. // */
  69. // next, click the button once it pops into view for the user
  70. // temporarily set a timer until I figure out a way to click the button without using unreliable manual timers
  71. // do note that in the case of timers, the rest of the code will continue to execute.
  72. // all the timer does is delay execution of a set of code until the set amount of time expires
  73. // other parts of code will still continue to execute when the timer is going on
  74. setTimeout(function(){
  75. document.getElementById('ContentWarningApprove').click();
  76. }, 100);
  77. //document.getElementsByClassName('approve').click();
  78. // this does not work
  79. //document.getElementsByClassName('approve')[0].click();
  80. // this works. however, ID is preferred over class
  81. // for some reason getElementsByClassName doesn't work sometimes. maybe ajax is still trying to load?
  82. //document.getElementById('ContentWarningApprove').click();
  83. // this works
  84.  
  85. }, false);
  86.  
  87.  
  88.  

QingJ © 2025

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