JAVlibrary磁力搜索

JAVlibrary磁力搜索,搜索引擎为btdigg与16magnet

  1. // ==UserScript==
  2. // @name JAVlibrary磁力搜索
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description JAVlibrary磁力搜索,搜索引擎为btdigg与16magnet
  6. // @author xhj,chatGPT
  7. // @match http://www.javlibrary.com/*
  8. // @match https://www.javlibrary.com/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 使用 XPath 获取元素
  17. function getElementByXPath(xpath) {
  18. return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  19. }
  20.  
  21. // 定义 XPath
  22. const xpath = '/html/body/div[3]/div[2]/table/tbody/tr/td[2]/div/div[1]/table/tbody/tr/td[2]';
  23.  
  24. // 获取包含文字的<td>元素
  25. const textElement = getElementByXPath(xpath);
  26. if (!textElement) {
  27. console.log('未找到指定的<td>元素');
  28. return;
  29. }
  30.  
  31. // 获取文字内容
  32. const textContent = textElement.textContent.trim();
  33. console.log('获取的文字:', textContent);
  34.  
  35. // 创建按钮元素
  36. const createButton = (label, url) => {
  37. const button = document.createElement('button');
  38. button.textContent = label;
  39. button.style.marginLeft = '5px';
  40. button.addEventListener('click', () => {
  41. window.open(url, '_blank');
  42. });
  43. return button;
  44. };
  45.  
  46. // 生成搜索URL
  47. const url1 = `https://btdig.com/search?q=${encodeURIComponent(textContent)}`;
  48. const url2 = `https://16mag.net/search?q=${encodeURIComponent(textContent)}`;
  49.  
  50. // 创建按钮
  51. const button1 = createButton('搜索BTDig', url1);
  52. const button2 = createButton('搜索16Mag', url2);
  53.  
  54. // 将按钮添加到表格后面
  55. const tableElement = textElement.closest('table');
  56. if (tableElement) {
  57. tableElement.after(button1, button2);
  58. } else {
  59. console.log('未找到包含表格的父元素');
  60. }
  61. })();