Rule34 Quick Buttons

Just a few buttons that a useful

  1. // ==UserScript==
  2. // @name Rule34 Quick Buttons
  3. // @namespace miep
  4. // @include *://rule34.xxx/*
  5. // @grant none
  6. // @version Final
  7. // @author jAstn
  8. // @description Just a few buttons that a useful
  9. // @require https://code.jquery.com/jquery-3.5.1.min.js
  10. // @icon https://i.imgur.com/m2kIFiy.png
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. // this function get exicuted when the document is ready so all the elements on the page are loaded and we can access everything we need for the scipt
  15. // first and only thing i just form the jquery libary but it has so many more things that are just nice to have (that we install with the @require https://code.jquery.com/jquery-3.5.1.min.js line)
  16. // libary = is basical a colection of code that you can use if you import the libary into the program
  17. $("document").ready(function() {
  18. var searchField = document.getElementsByName("tags")[0];
  19. var searchButton = document.getElementsByName("tag-search")[0];
  20.  
  21. function createButton(text, innerHTML) {
  22. var button = document.createElement("button");
  23. button.innerHTML = innerHTML;
  24. button.style.cursor = "pointer";
  25. button.style.margin = "2px";
  26. button.onclick = function() {
  27. // Appending the text to the searchField value
  28. searchField.value += " " + text;
  29.  
  30. // Triggering click event on the searchButton
  31. searchButton.click();
  32. };
  33. return button;
  34. }
  35.  
  36. // If you want to create a button just remove the // from the last line and copy the new buttons name down in tagSearchContainer
  37. var sortScoreButton = createButton("sort:score", "Sort by Score");
  38. var animatedButton = createButton("-animated -video", "No Animation");
  39. var sortIDButton = createButton("sort:id:desc", "Sort by ID");
  40. var sortScoreanimatedButton = createButton("sort:score -animated -video height:>1000", "Combined");
  41. var HeightButton = createButton("height:>1000", "Height");
  42. // var NAMEButton = createButton ("TAG THAT YOU WANT TO SEARCH", "TEXT ON THE BUTTON");
  43.  
  44. // Appending the buttons to the container div
  45. var tagSearchContainer = document.getElementsByClassName("tag-search")[0];
  46. tagSearchContainer.appendChild(sortScoreanimatedButton);
  47. tagSearchContainer.appendChild(sortScoreButton);
  48. tagSearchContainer.appendChild(animatedButton);
  49. tagSearchContainer.appendChild(sortIDButton);
  50. tagSearchContainer.appendChild(HeightButton);
  51. // tagSearchContainer.appendChild(NAMEButton);
  52. });