javdb_helper

添加推送磁力链接到 aria2 的下载按钮

  1. // ==UserScript==
  2. // @name javdb_helper
  3. // @version 1.0.0
  4. // @author 洪世贤
  5. // @include http*://*javdb.com/v/*
  6. // @description 添加推送磁力链接到 aria2 的下载按钮
  7. // @require https://code.jquery.com/jquery-2.1.4.min.js
  8.  
  9. // @namespace https://greasyfork.org/users/821273
  10. // ==/UserScript==
  11. const BASE_HOST = '' // Aria2 RPC 地址,例如 https://aria2.com:6800/
  12. const TOKEN = '' // Aria2 RPC 密钥
  13. // 下载到 Aria2
  14. const ariaDownload = function (download_url) {
  15. const url = `${BASE_HOST}/jsonrpc`
  16. var json_rpc = {
  17. jsonrpc: '2.0',
  18. id: '',
  19. method: 'aria2.addUri',
  20. params: [
  21. `token:${TOKEN}`,
  22. [download_url],
  23. ]
  24. };
  25. $.ajax({
  26. url: url,
  27. type: 'POST',
  28. crossDomain: true,
  29. processData: false,
  30. data: JSON.stringify(json_rpc),
  31. contentType: 'application/json',
  32. success: function (response) {
  33. const notifyElement = document.createElement("div")
  34. notifyElement.id = "notifyElement"
  35. notifyElement.className = "notification is-success"
  36. notifyElement.textContent = "发送成功 ~~"
  37. $(notifyElement).css({ position: 'fixed', right: '45%', bottom: '45%' })
  38. document.body.append(notifyElement)
  39. function removeNotify () {
  40. $("#notifyElement").remove()
  41. }
  42. setTimeout(removeNotify, 2000)
  43. }
  44. });
  45. }
  46.  
  47. // 添加推送到 Aria2 按钮
  48. $("#magnets-content td:last-child button").each(
  49. function () {
  50. $(this).parent().css('width', 170)
  51. const ariaButton = document.createElement('button');
  52. ariaButton.textContent = "发送到 Aria2"
  53. ariaButton.className = "button is-info is-light is-small "
  54. const that = $(this).attr('data-clipboard-text')
  55. ariaButton.onclick = function () {
  56. ariaDownload(that)
  57. }
  58. $(this).before(ariaButton)
  59. }
  60. )
  61.