EXHentai random gallery selector

adds links to random page and gallery on search pages

  1. // ==UserScript==
  2. // @name EXHentai random gallery selector
  3. // @namespace http://exhentai.org/
  4. // @version 1.1
  5. // @description adds links to random page and gallery on search pages
  6. // @author DikUln
  7. // @include http://exhentai.org/*
  8. // @include http://g.e-hentai.org/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. function randGal() {
  13. if (document.getElementById("dmi").children[0].innerHTML == "List") {
  14. window.location.href = document.getElementsByClassName("itg")[0].tBodies[0].getElementsByTagName("tr")[Math.floor(Math.random() * document.getElementsByClassName("itg")[0].tBodies[0].getElementsByTagName("tr").length - 1) + 1].getElementsByClassName("it5")[0].children[0].href;
  15. } else {
  16. window.location.href = document.getElementsByClassName("itg")[0].children[Math.floor(Math.random() * (document.getElementsByClassName("itg")[0].children.length - 1))].children[0].children[0].href;
  17. }
  18. }
  19.  
  20. function randPage() {
  21. sp(Math.floor(document.getElementsByClassName("ptt")[0].tBodies[0].getElementsByTagName("td")[(document.getElementsByClassName("ptt")[0].tBodies[0].getElementsByTagName("td").length - 2)].children[0].innerHTML * Math.random()));
  22. }
  23.  
  24. (function(){
  25. document.getElementById("dmo").innerHTML = '<div>Select random: <a id="randLink" href="#">gallery</a> <a id="randPageLink" href="#">page</a></div>' + document.getElementById("dmo").innerHTML;
  26. var myLink = document.getElementById("randLink");
  27. myLink.addEventListener("click", randGal, true);
  28. var myPageLink = document.getElementById("randPageLink");
  29. myPageLink.addEventListener("click", randPage, true);
  30. })();