Sleazy Fork is available in English.

Add button on exhentai searchbox from tag button

Add your favorite keyword/tag on the searchbox from tag button

  1. // ==UserScript==
  2. // @name Add button on exhentai searchbox from tag button
  3. // @description Add your favorite keyword/tag on the searchbox from tag button
  4. // @license MIT
  5. // @version 0.4
  6. // @match https://exhentai.org/g/*
  7. // @run-at context-menu
  8. // @namespace https://greasyfork.org/users/383371
  9. // ==/UserScript==
  10.  
  11.  
  12. function capitalize(str) {
  13. var tmp = str.toLowerCase().split(' ');
  14. for(let i = 0; i < tmp.length; i++) {
  15. tmp[i] = tmp[i].charAt(0).toUpperCase() + tmp[i].substring(1);
  16. }
  17. return tmp.join(' ');
  18. }
  19.  
  20. function add_tag(tag, name){
  21. let config = JSON.parse(window.localStorage.getItem('config'));
  22. if(!config){
  23. config = [];
  24. }
  25. config.push([tag, name]);
  26. window.localStorage.setItem('config', JSON.stringify(config));
  27. let search_tag_config = JSON.parse(window.localStorage.getItem('search_tag_config'));
  28. if(!search_tag_config){
  29. search_tag_config = [];
  30. if(config){
  31. for(let ele of config){
  32. search_tag_config.push(
  33. {
  34. 'key': ele[1],
  35. 'value': ele[0],
  36. 'color': '',
  37. }
  38. );
  39. }
  40. }
  41. }else{
  42. search_tag_config.push(
  43. {
  44. 'key': name,
  45. 'value': tag,
  46. 'color': '',
  47. }
  48. );
  49. }
  50. window.localStorage.setItem('search_tag_config', JSON.stringify(search_tag_config));
  51. }
  52.  
  53. (function() {
  54. if(document.activeElement.id.substring(0, 2) == 'ta'){
  55. let tag = document.activeElement.href.substring(document.activeElement.href.indexOf('tag/') + 4).replaceAll('+', ' ');
  56. let tmp = tag.split(':');
  57. let tag_namespace = tmp[0];
  58. let tag_value = tmp[1];
  59. tag_value += '$';
  60. if(tag_value.includes(' ')){
  61. tag_value = `"${tag_value}"`;
  62. }
  63. let name = prompt('name', capitalize(document.activeElement.innerText));
  64. if(!name){
  65. return;
  66. }
  67. add_tag(`${tag_namespace}:${tag_value}`, name);
  68. alert(`${tag_namespace}:${tag_value} added`);
  69. }else if(document.activeElement.href.includes('uploader')){
  70. let uploader = document.activeElement.text;
  71. let tag = `uploader:${uploader}`;
  72. let name = prompt('name', capitalize(uploader));
  73. if(!name){
  74. return;
  75. }
  76. add_tag(`${tag}`, name);
  77. alert(`${tag} added`);
  78. }
  79. })();