Sleazy Fork is available in English.

R34.XXX Favorites Button

Adds a favorite button to gallery pages on rule34.xxx.

  1. // ==UserScript==
  2. // @name R34.XXX Favorites Button
  3. // @namespace https://linktr.ee/GanbatGAN
  4. // @version 1.3
  5. // @description Adds a favorite button to gallery pages on rule34.xxx.
  6. // @author Ganbat
  7. // @match https://rule34.xxx/index.php?page=post&s=list&tags=*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=rule34.xxx
  9. // @grant GM_addStyle
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
  11. // @license Unlicense
  12. // ==/UserScript==
  13.  
  14. /* globals $ */
  15.  
  16. GM_addStyle ( `
  17. .galFavBtn {
  18. cursor: pointer;
  19. color: #009;
  20. }
  21. .galFavBtn:hover {
  22. color: #000;
  23. }
  24. ` );
  25.  
  26. function IBEButton(){
  27. const tpDetails = document.getElementById('thumbPlusDetailsOptions');
  28. const tpFavButton = document.createElement("div");
  29. tpFavButton.setAttribute('class', 'thumbPlusDetailsButton');
  30. tpFavButton.setAttribute('tooltip', 'Add to Favorites');
  31. tpFavButton.setAttribute('style', 'display: none;');
  32. tpFavButton.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m 22.051576,3.5701033 c -1.236895,-1.3415351 -2.934095,-2.080391 -4.77932,-2.080391 -1.379271,0 -2.642417,0.4360581 -3.754439,1.2959602 C 12.956703,3.2197252 12.448272,3.7507609 12,4.370576 11.55191,3.7509435 11.043297,3.2197252 10.482,2.7856725 9.3701616,1.9257704 8.1070149,1.4897123 6.7277442,1.4897123 c -1.8452255,0 -3.542607,0.7388559 -4.7795026,2.080391 -1.22212933,1.3258569 -1.89535776,3.137175 -1.89535776,5.1005301 0,2.0207786 0.7530753,3.8705626 2.36988086,5.8215216 1.4463566,1.745143 3.5251068,3.516721 5.9323587,5.568125 0.821984,0.700574 1.7537116,1.494666 2.7211706,2.340531 0.255581,0.223863 0.583537,0.347096 0.923706,0.347096 0.339987,0 0.668125,-0.123233 0.923342,-0.34673 0.967458,-0.846049 1.899733,-1.640506 2.722081,-2.341443 2.406888,-2.051041 4.485638,-3.822436 5.931994,-5.567762 1.616806,-1.950776 2.369699,-3.80056 2.369699,-5.8215206 0,-1.9631731 -0.673228,-3.7744912 -1.89554,-5.1003481 z m 0,0"></path></svg>'
  33. tpDetails.firstElementChild.appendChild(tpFavButton);
  34.  
  35. const targetNode = document.getElementById('thumbPlusPreviewLink');
  36. const config = { attributeFilter: [ 'href' ] };
  37.  
  38. const callback = function(mutationsList, observer) {
  39. let postID = String(targetNode.getAttribute('href')).replace(/index\.php.+id=/, '');
  40. tpFavButton.setAttribute('style', 'display: inline-block;');
  41. tpFavButton.setAttribute('onclick', 'post_vote(\''+ postID +'\', \'up\'); addFav(\''+ postID +'\'); $(this).setAttribute("style", "display: none;"); return false;');
  42. }
  43.  
  44. const observer = new MutationObserver(callback);
  45. observer.observe(targetNode, config);
  46. }
  47.  
  48. setTimeout(() => {
  49. if ($('#thumbPlusPreviewContainer').length) {
  50. IBEButton();
  51. } else {
  52. $('.thumb').each(function() {
  53. var postLink = $(this).children('a').first();
  54. var postID = $(this).attr('id').substring(1);
  55. postLink.after('<br /><div><b class="galFavBtn" onclick="post_vote(\''+ postID +'\', \'up\'); addFav(\''+ postID +'\'); $(this).parentElement.hide(); return false;">Add to Favorites</b></div>');
  56. });
  57. }
  58. }, 200);