Kemono.Party Blacklist

Blacklists posts by Creator ID

Від 03.07.2023. Дивіться остання версія.

  1. // ==UserScript==
  2. // @name Kemono.Party Blacklist
  3. // @namespace https://MeusArtis.ca
  4. // @version 1.2.3
  5. // @author Meus Artis
  6. // @description Blacklists posts by Creator ID
  7. // @icon https://www.google.com/s2/favicons?domain=kemono.party
  8. // @supportURL https://t.me/kemonoparty
  9. // @include /^https:\/\/kemono\.(party|su)\/.*$/
  10. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  11. // @license CC BY-NC-SA 4.0
  12. // ==/UserScript==
  13. const BlacklistStorage = window.localStorage;
  14. const BlacklistButton = document.createElement("BUTTON");
  15. const BlacklistButtonArtist = document.createElement("BUTTON");
  16. const Blacklisted = JSON.parse(localStorage.getItem("blacklist"));
  17. const ButtonArea = document.querySelector('.post__actions');
  18. const ButtonAreaArtist = document.querySelector('.user-header__actions');
  19. const HeadMeta = document.querySelector("meta[name='user']");
  20. const HeadMetaArtist = document.querySelector("meta[name='artist_name']");
  21. const styleSheet = document.createElement("style");
  22. const styles = `.creator__blacklist{color:#ddd;font-weight:700;text-shadow:#000 0 0 3px,#000 -1px -1px 0px,#000 1px 1px 0;background-color:transparent;border:transparent}.user-header__blacklist{box-sizing:border-box;font-weight:700;color:#fff;text-shadow:#000 0 0 3px,#000 -1px -1px 0px,#000 1px 1px 0;background-color:transparent;border:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}`;
  23. if ("blacklist" in BlacklistStorage) {
  24. console.log("Blacklist Exists");
  25. } else {
  26. alert("Blacklist does not exist, creating a new one");
  27. BlacklistStorage.setItem("blacklist", "[]");
  28. }
  29. var HeadMetaID = document.querySelector("meta[name='id']");
  30. if (HeadMeta) {
  31. console.log("Blacklist Enabled (Post Page)");
  32. var HeadMetaID = HeadMeta.getAttribute("content");
  33. ButtonArea.appendChild(BlacklistButton);
  34. } else if (HeadMetaArtist) {
  35. console.log("Blacklist Enabled (Artist Page)");
  36. var HeadMetaID = HeadMetaID.getAttribute("content");
  37. ButtonAreaArtist.appendChild(BlacklistButton);
  38. } else {
  39. console.log("Blacklist Enabled (Recent Posts/Search Page)");
  40. }
  41. const UnBlacklist = Blacklisted.indexOf(HeadMetaID);
  42. document.head.appendChild(styleSheet);
  43. styleSheet.innerText = styles;
  44. styleSheet.type = "text/css";
  45. BlacklistButton.classList.add("creator__blacklist");
  46. BlacklistButton.type = "button";
  47. if (Blacklisted.indexOf(HeadMetaID) !== -1) {
  48. BlacklistButton.innerHTML = '<span class="creator__blacklist-icon">⛒</span><span>Blacklisted</span>';
  49. BlacklistButton.onclick = function () {
  50. Blacklisted.splice(UnBlacklist, 1);
  51. BlacklistStorage.setItem("blacklist", JSON.stringify(Blacklisted));
  52. alert("Creator Unblacklisted");
  53. location.reload();
  54. };
  55. } else {
  56. BlacklistButton.innerHTML = '<span class="creator__blacklist-icon">⛔</span><span>Blacklist</span>';
  57. BlacklistButton.onclick = function () {
  58. Blacklisted.push(HeadMetaID);
  59. BlacklistStorage.setItem("blacklist", JSON.stringify(Blacklisted));
  60. alert("Creator Blacklisted");
  61. location.reload();
  62. };
  63. }
  64. Blacklisted.forEach(function (item) {
  65. $("article[data-user='" + item + "']").remove();
  66. });
  67.  
  68. function waitForElementToDisplay(selector, callback, checkFrequencyInMs, timeoutInMs) {
  69. var startTimeInMs = Date.now();
  70. (function loopSearch() {
  71. if (document.querySelector(selector) != null) {
  72. callback();
  73. return;
  74. }
  75. else {
  76. setTimeout(function () {
  77. if (timeoutInMs && Date.now() - startTimeInMs > timeoutInMs)
  78. return;
  79. loopSearch();
  80. }, checkFrequencyInMs);
  81. }
  82. })();
  83. };
  84.  
  85. waitForElementToDisplay("#paginator-top > menu",function(){
  86. window.addEventListener('hashchange', function(){
  87. Blacklisted.forEach(function (item) {
  88. $("a[href='/patreon/user/" + item + "']").remove(); //for recently updated
  89. $("a[href='/fanbox/user/" + item + "']").remove(); //this only works for the 100ms after a page load before it reloads itself (why?)
  90. $("a[href='/gumroad/user/" + item + "']").remove(); //i dont get paid for this, im not a developer, i dont know javascript, regex doesnt work, stop reading my comments, fuck you.
  91. $("a[href='/subscribestar/user/" + item + "']").remove();
  92. $("a[href='/dlsite/user/" + item + "']").remove();
  93. $("a[href='/discord/server/" + item + "']").remove();
  94. $("a[href='/fantia/user/" + item + "']").remove();
  95. $("a[href='/boosty/user/" + item + "']").remove();
  96. $("a[href='/afdian/user/" + item + "']").remove();
  97. });
  98. });
  99. Blacklisted.forEach(function (item) {
  100. $("a[href='/patreon/user/" + item + "']").remove(); //for recently updated
  101. $("a[href='/fanbox/user/" + item + "']").remove(); //this only works for the 100ms after a page load before it reloads itself (why?)
  102. $("a[href='/gumroad/user/" + item + "']").remove(); //i dont get paid for this, im not a developer, i dont know javascript, regex doesnt work, stop reading my comments, fuck you.
  103. $("a[href='/subscribestar/user/" + item + "']").remove();
  104. $("a[href='/dlsite/user/" + item + "']").remove();
  105. $("a[href='/discord/server/" + item + "']").remove();
  106. $("a[href='/fantia/user/" + item + "']").remove();
  107. $("a[href='/boosty/user/" + item + "']").remove();
  108. $("a[href='/afdian/user/" + item + "']").remove();
  109. });
  110. },100,30000); //page takes longer than 30 seconds to load? (as it sometimes does), rip you then