Sleazy Fork is available in English.

JAVLib tag助手

鼠标悬停在javLibrary图片上时显示该视频类型。

  1. // ==UserScript==
  2. // @name JAVLib tag助手
  3. // @namespace JAVLib tag助手
  4. // @description 鼠标悬停在javLibrary图片上时显示该视频类型。
  5.  
  6. // @include http*://www.p26y.com/*
  7. // @include http*://www.k25m.com/*
  8. // @include http*://www.javlibrary.com/*
  9. // @include http*://www.k25m.com/*
  10. // @include http*://avmoo.online/*
  11.  
  12.  
  13. // @version 1.141
  14. // @run-at document-end
  15. // @grant GM_xmlhttpRequest
  16. // @grant GM_setClipboard
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @grant GM_addStyle
  20. // @grant GM_registerMenuCommand
  21. // ==/UserScript==
  22.  
  23. "use strict";
  24. let videos = document.querySelector(".videos");
  25. let showTags = true
  26. function removeBeforeFirstSpace(str) {
  27. return str.split(' ').slice(1).join(' ');
  28. }
  29.  
  30. function delay(ms) {
  31. return new Promise(resolve => setTimeout(resolve, ms));
  32. }
  33.  
  34. async function getWithRetry(url, attempts, delayDuration) {
  35. for (let i = 0; i < attempts; i++) {
  36. try {
  37. // Your request logic here
  38. await delay(delayDuration);
  39. return; // Success, exit loop
  40. } catch (error) {
  41. console.error(`Attempt ${i + 1} failed:`, error);
  42. if (i < attempts - 1) {
  43. await delay(delayDuration); // Wait before retrying
  44. } else {
  45. throw error; // Max attempts reached, throw error
  46. }
  47. }
  48. }
  49. }
  50.  
  51. async function getInformation() {
  52. const videoPage = document; // Refers to the whole current HTML document
  53. const url = window.location.href
  54. const genres = Array.from(videoPage.querySelectorAll("#video_genres .genre")).map(genre => genre.innerText);
  55. const code = videoPage.querySelector("#video_id .text").innerText;
  56. const director = videoPage.querySelector("#video_director .text").innerText;
  57. const company = videoPage.querySelector("#video_maker .text").innerText;
  58. const actors = Array.from(videoPage.querySelectorAll(".cast .star")).map(star => star.innerText);
  59. const title_jp = removeBeforeFirstSpace(videoPage.querySelector(".post-title.text").innerText);
  60. const release_date = videoPage.querySelector("#video_date .text").innerText;
  61. const poster = videoPage.querySelector("#video_jacket_img").src;
  62. // Make a POST request using jQuery's $.ajax
  63. $.ajax({
  64. type: "POST",
  65. url: "https://www.mingren.life/av/general",
  66. contentType: "application/json", // Set the content type to application/json
  67. dataType: "json",
  68. data: JSON.stringify([{
  69. url,
  70. genres,
  71. code,
  72. director,
  73. company,
  74. actors,
  75. title_jp,
  76. title_en: "",
  77. release_date,
  78. poster
  79. }]),
  80. success: function(result) {
  81. console.log("Request succeeded:", result);
  82. },
  83. error: function(err) {
  84. console.error("Request failed:", err);
  85. }
  86. });
  87. }
  88.  
  89. var good = ["监禁", "轮奸", "凌辱", "轮奸", "SM", "拘束", "调教", "强奸", "肛交"]
  90. var get_eng_title = function(url, data) {
  91. let en_url = (url.replace("/cn/", "/en/"))
  92. }
  93.  
  94. function hasCommonElement(array1, array2) {
  95. const set1 = new Set(array1);
  96. return array2.some(element => set1.has(element));
  97. }
  98.  
  99. function applyTags(videoElement, genres) {
  100. // Logic to apply tags to the video element
  101. const tags = genres.join(', ');
  102. videoElement.setAttribute("data-toggle", "tooltip");
  103. videoElement.setAttribute("title", tags);
  104. if (hasCommonElement(genres, good)) {
  105. videoElement.style.color = "#e3a807"; // Example styling, adjust as necessary
  106. }
  107. }
  108.  
  109. var display_not_on_server = function(element){
  110. var buttonText = $("<span>").text("未更新").css("background-color", "pink"); // Create a span for the text and set the background color to pink
  111. var firstDiv = $(element).children("div").first(); // Get the first div child of the element
  112. firstDiv.append(" ").append(buttonText); // Append the span to the first div child
  113. };
  114.  
  115. var addInformation = function(result) {
  116. console.log(result)
  117. let subtitle = result.DownloadMovies[0].subtitle
  118. let downloaded = true
  119. let mosic = result.DownloadMovies[0].mosic
  120. let error = result.DownloadMovies[0].error
  121. let torrent = result.DownloadMovies[0].torrent_name
  122. let dataTable = $("#video_info")[0]
  123. let innerHtml = `<div id="" class="item">
  124. <table>
  125. <tbody><tr>
  126. <td class="header" ${error ? 'style="color: red"' : ""}>种子:</td>
  127. <td class="text"><span id="cast36486" class="cast"><span class="star"><a rel="tag">${torrent}</a></span></td>
  128. <td class="icon"></td>
  129. </tr>
  130. </tbody></table>
  131. <table>
  132. <tbody><tr>?
  133. <td class="header" >马赛克:</td>
  134. <td class="text"><span id="cast36486" class="cast"><span class="star"><a rel="tag">${mosic ? "有" : "无"}</a></span></td>
  135. <td class="icon"></td>
  136. </tr>
  137. </tbody></table>
  138.  
  139. </div>
  140. <div id="" class="item">
  141. <table>
  142. <tbody><tr>
  143. <td class="header">字幕:</td>
  144. <td class="text"><span id="cast36486" class="cast"><span class="star"><a rel="tag">${subtitle ? "有" : "无"}</a></span></td>
  145. <td class="icon"></td>
  146. </tr>
  147. </tbody></table>
  148. </div>`
  149. const d = document.createElement("div")
  150. d.innerHTML = innerHtml
  151. dataTable.appendChild(d)
  152. let title = $(".post-title")[0]
  153. let title_cn = document.createElement("div")
  154. title_cn.innerHTML = title.innerHTML
  155. title_cn.innerText = result.title_cn
  156. $("#video_title")[0].appendChild(title_cn)
  157. }
  158.  
  159. const promises = [];
  160. if (videos) {
  161. // if this is a list page
  162. $('.video').each((index, video) => {
  163. // Extract the code as before
  164. const code = ($(video).find("a")[0].title.split(" ")[0]).replace(/-/g, '');
  165. // Create a new promise for each AJAX request and add it to the promises array
  166. const promise = new Promise((resolve, reject) => {
  167. $.ajax({
  168. url: `https://www.mingren.life/av/${code}`,
  169. success: (result) => {
  170. if (!result) {
  171. // Handle no result scenario
  172. } else if (result.DownloadMovies && result.DownloadMovies.length > 0) {
  173. if (result.DownloadMovies[0].subtitle) {
  174. $(video).css("background-color", "pink");
  175. } else {
  176. $(video).css("background-color", "#c6eb34");
  177. }
  178. }
  179. resolve({ result, video });
  180. },
  181. error: (error) => {
  182. // Reject the promise in case of an error
  183. reject(error);
  184. }
  185. });
  186. });
  187.  
  188. promises.push(promise);
  189. });
  190.  
  191. // Use Promise.all to handle all the promises together
  192. Promise.all(promises).then(async (results) => {
  193. // Process each movie that need to add to db
  194. var new_movies = results.filter(({result, video}) => !(result))
  195. var old_movies = results.filter(({result, video}) => !!(result))
  196.  
  197. // for new movies, we need to extract all info and eng subtitles. However, set a 3 sec limit
  198. for (const {video} of new_movies) {
  199. // Assuming get_tags is properly defined to handle the video element
  200. display_not_on_server($(video).find("a")[0]);
  201. }
  202. // for all movies, we need to extract tags only if when showTags is true
  203. results.forEach(({result, video}) => {
  204. if (showTags && result && result.MovieGenres) {
  205. // Assuming result.genres is an array of genre tags for the movie
  206. applyTags($(video).find("a")[0], result.MovieGenres.map(genre => genre.Genres.name))
  207. // for old movies, we want to check result[i].DownloadMovies[0].error is false
  208. if (result.DownloadMovies.length > 0 && result.DownloadMovies[0].error) {
  209. $(video).css("background-color", "red");
  210. }
  211. }
  212.  
  213. });
  214.  
  215.  
  216. }).catch(error => {
  217. // Handle any error that occurred during any of the ajax calls
  218. console.error("An error occurred: ", error);
  219. });
  220. } else {
  221. // this is a single page
  222. let code = document.querySelector("#video_id .text").innerText
  223. let downloaded = false
  224. $.ajax({
  225. url: `https://www.mingren.life/av/${code}`,
  226. success: (result) => {
  227. if (! result) {
  228. getInformation()
  229. } else if (result.DownloadMovies.length > 0) {
  230. addInformation(result)
  231. }
  232. },
  233. error: (error) => {
  234. // Reject the promise in case of an error
  235. reject(error);
  236. }
  237. });
  238. }
  239.  
  240.  
  241.