Remove Favorite Hotkey

Allows you to press g (or another key) to remove favorites from the post page.

  1. // ==UserScript==
  2. // @name Remove Favorite Hotkey
  3. // @version 1
  4. // @description Allows you to press g (or another key) to remove favorites from the post page.
  5. // @author Yoboies
  6. // @match https://rule34.xxx/index.php?page=post&s=view&id=*
  7. // @match https://rule34.xxx/index.php?page=favorites&s=view&id=*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=rule34.xxx
  9. // @grant GM.getValue
  10. // @grant GM.setValue
  11. // @license MIT
  12. // @namespace https://greasyfork.org/users/1345312
  13. // ==/UserScript==
  14.  
  15. (async function() {
  16. 'use strict';
  17. if(location.href.indexOf('https://rule34.xxx/index.php?page=post') == 0){
  18. var hotkey = "KeyG"; //REPLACE WITH WHATEVER KEY WORKS FOR YOU
  19.  
  20. document.addEventListener('keydown', keyPress);
  21.  
  22. function keyPress(e) {
  23. if(e.code==hotkey){
  24. var oldURL = location.href;
  25. var newURL = oldURL.replace('page=post&s=view','page=favorites&s=delete');
  26. GM.setValue('id',Date.now() + '\n' + oldURL);
  27. document.location.href = newURL;
  28. }
  29. }
  30.  
  31. } else if (location.href.indexOf('https://rule34.xxx/index.php?page=favorites') == 0){
  32. var ID = await GM.getValue('id', '');
  33. if(ID && Date.now() - ID.split('\n')[0] < 1*1000){
  34. ID = ID.split('\n')[1];
  35. document.location.href = ID;
  36. }
  37. }
  38. })();