Pixiv AI Filter && Zoom

Hover over Image to determine whether it's AI Generated | 'Zoom' Images by making them larger on hover | Works in "Users Your Following" (their Arts) Tab

  1. // ==UserScript==
  2. // @name Pixiv AI Filter && Zoom
  3. // @namespace https://www.youtube.com/@NurarihyonMaou
  4. // @version 0.5
  5. // @description Hover over Image to determine whether it's AI Generated | 'Zoom' Images by making them larger on hover | Works in "Users Your Following" (their Arts) Tab
  6. // @author NurarihyonMaou
  7. // @match https://www.pixiv.net/bookmark_new_illust.php*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=pixiv.net
  9. // @require http://code.jquery.com/jquery-3.5.1.min.js
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // ==/UserScript==
  13.  
  14. const $ = window.jQuery;
  15.  
  16. let element;
  17.  
  18. let userID;
  19. let hideAI = GM_getValue('hideAI') ?? false;
  20. let profilesPostingAI = GM_getValue('profilesPostingAI') ?? [];
  21.  
  22. let zoomToggle = true;
  23.  
  24. function hideAIGenerated(){
  25. $.each(profilesPostingAI, function(index, profile){
  26. $.each(document.querySelectorAll(`[data-gtm-value='${profile}']`), function(index, illustToHide){
  27. $(illustToHide).parent().parent().parent().css("display", "none");
  28. });
  29. });
  30. }
  31.  
  32. function showAIGenerated(){
  33. $.each(profilesPostingAI, function(index, profile){
  34. $.each(document.querySelectorAll(`[data-gtm-value='${profile}']`), function(index, illustToHide){
  35. $(illustToHide).parent().parent().parent().css("display", "block");
  36. });
  37. });
  38. }
  39.  
  40.  
  41. function init() {
  42. let illusts = document.querySelectorAll('div[type=illust]');
  43. let allImages = $('li.wHEbW');
  44.  
  45. if (allImages.length > 0 && illusts.length > 0) {
  46.  
  47.  
  48. $(allImages).hover(function () {
  49. if(!zoomToggle)
  50. return;
  51.  
  52. let delay=500, setTimeoutConst;
  53. element = $(this);
  54. setTimeoutConst = setTimeout(function() {
  55.  
  56. $(element).find('*').not("button.fgVkZi").not("svg.fYcrPo").not("div.hHNegy").not("div.Sxcoo").not("div.liXhix").not("div.gUquFP").not("div.efxZOo").not("span").not("svg").not("a.sc-d98f2c-0").not("div.hMqBzA").not("div.jtpclu").not("a.dghpiU").not("img").not("div.cIllir").not("div.icsUdQ").not("div.eMfHJB").css("width", "400px").css("height", "400px").css("z-index", 999);
  57. }, delay);
  58. }, function () {
  59.  
  60. $(element).find('*').not("button.fgVkZi").not("svg.fYcrPo").not("div.hHNegy").not("div.Sxcoo").not("div.liXhix").not("div.gUquFP").not("div.efxZOo").not("span").not("svg").not("a.sc-d98f2c-0").not("div.hMqBzA").not("div.jtpclu").not("a.dghpiU").not("img").not("div.cIllir").not("div.icsUdQ").not("div.eMfHJB").css("width", "").css("height", "").css("z-index", "");
  61. $(element).find("div.iGXOdz").css("width", "").css("height", "").css("z-index", "");
  62. }
  63. ), function(){
  64. clearTimeout(setTimeoutConst);
  65. };
  66.  
  67. let R18 = document.querySelectorAll("a[href='/bookmark_new_illust_r18.php']");
  68. let InputHideAI = document.querySelectorAll("input[id='HideAI']").length == 0 ? false : true;
  69.  
  70. if(hideAI){
  71. hideAIGenerated();
  72. if(!InputHideAI)
  73. $(R18).after(`<input type='checkbox' id='HideAI' checked/>`);
  74. }
  75. else{
  76. if(!InputHideAI)
  77. $(R18).after(`<input type='checkbox' id='HideAI'/>`);
  78. }
  79.  
  80. $("body").on('click', "input#HideAI", function () {
  81. hideAI = $(this).prop('checked');
  82. GM_setValue('hideAI', hideAI);
  83. if(hideAI)
  84. hideAIGenerated();
  85. else
  86. showAIGenerated();
  87. });
  88.  
  89.  
  90. $.each(illusts, function(index, illust){
  91. let hovered = false;
  92.  
  93. let delay=100, setTimeoutConst;
  94. $(illust).hover(function(){
  95.  
  96. setTimeoutConst = setTimeout(function() {
  97. if(!hovered)
  98. $.ajax({
  99. method: 'GET',
  100. url: "https://www.pixiv.net/ajax/illust/"+$(illust).find('a').attr('href').split('/')[3],
  101. complete: function(data){
  102. userID = data.responseJSON.body.userId;
  103. if(data.responseJSON.body.aiType == 2){
  104. $(illust).append("<p>AI Generated</p>");
  105. if(profilesPostingAI.indexOf(userID) < 0){
  106. profilesPostingAI.push(userID);
  107. hideAIGenerated();
  108. GM_setValue('profilesPostingAI', profilesPostingAI);
  109. }
  110. }
  111. },
  112. error: function(error){
  113. console.error(error);
  114. }
  115. });
  116. hovered = true;
  117. }, delay);
  118. }, function(){
  119. clearTimeout(setTimeoutConst);
  120. });
  121. });
  122.  
  123. } else {
  124. setTimeout(init, 0);
  125. }
  126. };
  127.  
  128. document.addEventListener("keydown", (e) => {
  129. if(e.which == 90)
  130. zoomToggle = !zoomToggle;
  131. else
  132. return;
  133. });
  134.  
  135. init();
  136.  
  137. let previousUrl = '';
  138. const observer = new MutationObserver(function(mutations) {
  139. if (window.location.href !== previousUrl) {
  140. if(previousUrl != '' && window.location.href.indexOf("https://www.pixiv.net/bookmark_new_illust.php") != -1)
  141. init();
  142. previousUrl = window.location.href;
  143. }
  144. });
  145. const config = {subtree: true, childList: true};
  146.  
  147. observer.observe(document, config);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址