nhentai block popunders

Blocks popunder ads on nhentai

  1. // ==UserScript==
  2. // @name nhentai block popunders
  3. // @namespace sayixz01icji0pgmio1f4ayoth4vpuj2
  4. // @description Blocks popunder ads on nhentai
  5. // @license MIT License
  6. // @match *://*.nhentai.net/*
  7. // @version 1.1
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. /* jshint bitwise: true, curly: true, eqeqeq: true, esversion: 6,
  13. funcscope: false, futurehostile: true, latedef: true, noarg: true,
  14. nocomma: true, nonbsp: true, nonew: true, notypeof: false,
  15. shadow: outer, singleGroups: true, strict: true, undef: true,
  16. unused: true, varstmt: true, browser: true */
  17.  
  18. (function () {
  19. "use strict";
  20. const HOUR = 60 * 60 * 1000;
  21.  
  22. // Next popunder in 2h
  23. function killPopunders() {
  24. const key = "popunder_state";
  25.  
  26. let state;
  27.  
  28. try {
  29. let savedState = localStorage.getItem(key);
  30.  
  31. if (savedState) {
  32. state = JSON.parse(savedState);
  33. }
  34. } catch (ignore) {}
  35.  
  36. if (!state) {
  37. state = {};
  38. }
  39.  
  40. state.lock_until = Date.now() + 2 * HOUR;
  41.  
  42. try {
  43. localStorage.setItem(key, JSON.stringify(state));
  44. } catch (ignore) {}
  45. }
  46.  
  47. killPopunders();
  48.  
  49. // Call this again every hour just to make sure
  50. setInterval(killPopunders, HOUR);
  51. })();