ExHentai - Preload next page

Loosely inspired by "Handy ExHentai" script. Now loads more pages by nesting iFrames.

  1. // ==UserScript==
  2. // @name ExHentai - Preload next page
  3. // @version 1.1
  4. // @namespace exhentai-preload-page
  5. // @author BlindJoker
  6. // @homepage https://github.com/BlindJoker
  7. // @description Loosely inspired by "Handy ExHentai" script. Now loads more pages by nesting iFrames.
  8. // @match http://exhentai.org/s/*
  9. // @match http://g.e-hentai.org/s/*
  10. // @run-at document-end
  11. // @grant none
  12. // ==/UserScript==
  13. /*
  14. * Let the user scripts or content scripts running in an annoymous function.
  15. */
  16. (function (window) {
  17. "use strict";
  18.  
  19. var pnext = document.getElementById("next").href;
  20.  
  21. // Prevents possible infinite loadings
  22. if(window.self !== window.top && window.location.href == pnext) {
  23. console.log("finished loading everything");
  24. return;
  25. }
  26.  
  27. var nframe = document.createElement("iframe");
  28. nframe.src = pnext;
  29. nframe.id = "nframe";
  30. nframe.style.width = "1px";
  31. nframe.style.height = "1px";
  32. nframe.style.border = "none";
  33.  
  34. document.getElementById("img").addEventListener('load', function() {
  35. document.body.appendChild(nframe);
  36. });
  37.  
  38. var script = document.createElement('script');
  39.  
  40. script.type = "text/javascript";
  41. script.innerHTML = "var uweo = update_window_extents;" +
  42. "update_window_extents = function() {" +
  43. " uweo();" +
  44. " document.getElementById('img').addEventListener('load', function() {" +
  45. " document.getElementById('nframe').src = document.getElementById('next').href;" +
  46. " });" +
  47. "}";
  48.  
  49. document.head.appendChild(script);
  50. }) (window);