Sleazy Fork is available in English.

hypnopics-collective image fixer

changes thumbnails href to full image for hover add ons - requires click-based get request because no pattern

  1. // ==UserScript==
  2. // @name hypnopics-collective image fixer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description changes thumbnails href to full image for hover add ons - requires click-based get request because no pattern
  6. // @author You
  7. // @match https://hypnopics-collective.net/smf_forum/index.php?action=gallery*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. let scriptTag = document.createElement("script");
  12. scriptTag.src = "https://code.jquery.com/jquery-2.2.4.js";
  13. document.querySelector("head").appendChild(scriptTag);
  14.  
  15. newArr = Array.prototype.slice.call(document.getElementsByClassName("smalltext"), 0, document.getElementsByClassName("smalltext").length - 2);
  16.  
  17. newArr.forEach(el => el.innerHTML += el.innerText.slice(-5) === "Guest" ? "<br><span class='changeImg'>Change thumbnail href</span>" : "<span class='changeImg'>Change thumbnail href</span>");
  18.  
  19. Array.prototype.forEach.call(document.getElementsByClassName("changeImg"), function(el) {
  20. el.addEventListener("click", function(e) {
  21. el.innerText = "Changing...";
  22. $.ajax({
  23. type: "GET",
  24. url: el.parentNode.parentNode.children[window.location.href.match(/id=\d+/) || window.location.href.match(/u=\d+/) ? 1 : 0].href,
  25. success: function(data) {
  26. el.parentNode.parentNode.children[window.location.href.match(/id=\d+/) || window.location.href.match(/u=\d+/) ? 1 : 0].href = data.match(/https:\/\/hypnopics-collective\.net\/smf_forum\/gallery\/\d+\/\d+(-\d+)*\.\w+/)[0];
  27. el.innerText = "Changed!";
  28. },
  29. error: function(data) {
  30. console.log("error in ajax", error);
  31. }
  32. });
  33. });
  34. });