Tag Hiding

Hides Tags/Namespaces via regex

  1. // ==UserScript==
  2. // @name Tag Hiding
  3. // @version 1.08
  4. // @description Hides Tags/Namespaces via regex
  5. // @author Hauffen
  6. // @include /https?:\/\/(e-|ex)hentai\.org\/.*/
  7. // @require https://code.jquery.com/jquery-3.4.1.min.js
  8. // @namespace https://greasyfork.org/users/285675
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. let $ = window.jQuery, index = 0;
  13. let elements, data;
  14. if ($('.gl1e').length) {
  15. elements = $('.itg > tbody > tr');
  16. data = $('td[class^="gl1"] > div > a');
  17. } else if ($('.gl1c').length) {
  18. elements = $('.gltc tr').first().nextAll();
  19. data = $('.glname > a');
  20. } else if ($('.gl1t').length) {
  21. elements = $('.gl1t');
  22. data = $('.gl1t > a');
  23. } else {
  24. elements = $('.gltm tr').first().nextAll();
  25. data = $('.glname > a');
  26. }
  27. hide();
  28.  
  29. function hide() {
  30. var reqList = [];
  31. for (var i = 0; i + index < data.length; i++) {
  32. if (data[i + index] == undefined) continue;
  33. var str = data[i + index].href.split('/');
  34. reqList[i] = [str[4], str[5]];
  35. }
  36. while (reqList.length > 25) reqList.pop();
  37. var request = {"method": "gdata", "gidlist": reqList, "namespace": 1};
  38.  
  39. var req = new XMLHttpRequest();
  40. req.onreadystatechange = e => {
  41. if (req.readyState == 4) {
  42. if (req.status == 200) {
  43. var apirsp = JSON.parse(req.responseText);
  44. for (var i = 0; i < apirsp.gmetadata.length; i++) {
  45. if (apirsp.gmetadata[i].tags.some(tag => /^parody:/.test(tag))) { // Edit the /^parody:/ to whatever you want
  46. $(elements[i + index]).css({display: 'none'});
  47. }
  48. }
  49. index += 25;
  50. if (data.length > 25 && index < data.length) hide();
  51. } else {
  52. console.error();
  53. }
  54. }
  55. }
  56. req.open("POST", document.location.origin + "/api.php", true);
  57. req.send(JSON.stringify(request));
  58. }
  59. })();