hacg.* ?

司机工具

  1. // ==UserScript==
  2. // @name hacg.* ?
  3. // @author _
  4. // @namespace 908869191@qq.com
  5. // @description 司机工具
  6. // @version 0.23
  7. // @include http://*.hacg.*/*
  8. // @include https://*.hacg.*/*
  9. // @include http://*.llss.me/*/*
  10. // @include https://*.llss.me/*/*
  11. // @require http://code.jquery.com/jquery-1.11.0.min.js
  12. // @grant GM_setClipboard
  13. // @create 2017年01月13日13:11:50
  14. // @lastmodified 2017年01月13日13:12:00
  15. // @copyright 2017+, _
  16. // @run-at document-end
  17. // @note 2017年01月13日13:13:18 第一版本
  18. // @note 2017年01月29日01:31:54 更新域名范围
  19. // ==/UserScript==
  20.  
  21.  
  22. // magnet:?xt=urn:btih:dfd
  23. var brow = [
  24. "<(~︶~)>",
  25. "φ(≧ω≦*)♪",
  26. "(艹皿艹 )",
  27. "( ̄_, ̄ )"
  28. ];
  29.  
  30. var torrents = [];
  31. (function ($) {
  32. 'use strict';
  33. var $ele = $('.entry-content').children();
  34. $.each($ele, function (index, item) {
  35. var $item = $(item);
  36. var maybeTorrent = $item.text().trim();
  37. var reg = new RegExp("[a-zA-Z0-9]{32}|[a-zA-Z0-9]{40}", "g");
  38. if (reg.test(maybeTorrent)) { // is torrent
  39. var text = maybeTorrent.match(reg);
  40. $.each(text, function (index, val) {
  41. $item.append('<br/>');
  42. var $a = '<a class="J-hocgin-zclip" '
  43. + 'href="magnet:?xt=urn:btih:' + val + '" name="' + val + '">'
  44. + brow[parseInt(Math.random() * brow.length)] + ' ~ ' + val
  45. + '</a>';
  46. $item.append($a);
  47. torrents.push(val);
  48. });
  49. }
  50. });
  51.  
  52. // Div
  53. var $div = $('<div style="display: inline-block;'
  54. + 'background: rgba(197, 197, 197, 0.22);'
  55. + 'padding:5px 5px;'
  56. + 'border-radius: 5px;'
  57. + 'box-shadow: 0 0 0 1px hsla(0,0%,100%,.3) inset, 0 0.2em 1em rgba(0, 0, 0, 0.31);'
  58. + 'top: 40px;'
  59. + 'right: 20px;'
  60. + 'position: fixed;'
  61. + 'text-align: center"></div>');
  62.  
  63. // header
  64. var $header = $('<div style="text-align: center">'
  65. + 'φ(≧ω≦*)♪'
  66. + '</div>');
  67. $div.append($header);
  68. $div.append('<hr style="margin: 2px;"/>');
  69.  
  70.  
  71. // content
  72. if (torrents.length > 0) {
  73. $.each(torrents, function (index, torrent) {
  74. var $p = $('<p style="margin: 0;"></p>');
  75. $p.append($('<a href="magnet:?xt=urn:btih:' + torrent + '"' +
  76. ' style="margin-right: 5px;">迅雷下载</a>'));
  77. var $a = $('<a href="javascript:void;" ' +
  78. 'style="margin-right: 5px;">复制</a>');
  79. bindCopyEvent($a, 'magnet:?xt=urn:btih:' + torrent, function (e) {
  80. $(e).text("已复制");
  81. });
  82. $p.append($a);
  83. $p.append($('<a href="#' + torrent + '">巡视</a>'));
  84.  
  85. $div.append($p);
  86. });
  87. }else {
  88. $div.append('<p style="text-align: center;margin: 0;">车不见了?</p>');
  89. }
  90.  
  91. // tool bar
  92. $div.append('<hr style="margin: 2px;"/>');
  93. var $toolbar = $('<div style="text-align: center"></div>');
  94. var $allDownload = $('<a href="#" style="margin-right: 5px;">全部下载</a>');
  95. var allTorrent = '';
  96. $.each(torrents, function (index, val) {
  97. allTorrent += 'magnet:?xt=urn:btih:' + val+"\n";
  98. });
  99. bindCopyEvent($allDownload,allTorrent, function (e) {
  100. $(e).text("复制完成");
  101. });
  102. $toolbar.append($allDownload);
  103. $toolbar.append('<a href="#" style="margin-right: 5px;">顶部</a>');
  104. var $share = $('<a href="#">分享页面</a>');
  105. bindCopyEvent($share, window.location.href, function (e) {
  106. $(e).text("复制完成");
  107. });
  108. $toolbar.append($share);
  109. $div.append($toolbar);
  110.  
  111.  
  112. $('body').append($div);
  113. // console.log("Say Bye.")
  114.  
  115. })(jQuery);
  116.  
  117. function bindCopyEvent(e, val, callback) {
  118. var $e = $(e);
  119. $e.data("text-clip", val);
  120. $e.on('click', function () {
  121. var data = $(this).data("text-clip");
  122. GM_setClipboard(data);
  123. if (!!callback) {
  124. callback(this);
  125. }
  126. });
  127. }