Snap Links Mod

从网页中批量复制、打开链接,选择复选框

  1. // ==UserScript==
  2. // @name Snap Links Mod
  3. // @description 从网页中批量复制、打开链接,选择复选框
  4. // @name:en Snap Links Mod
  5. // @description:en snap Links(open, copy), radios, chenkboxs, images from website
  6. // @author Griever, ywzhaiqi, lastdream2013, Hanchy Hill
  7. // @namespace http://minhill.com/
  8. // @homepageURL https://greasyfork.org/en/scripts/25051/
  9. // @include http*
  10. // @version 2021.07.05
  11. // @license The MIT License (MIT); http://opensource.org/licenses/MIT
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_openInTab
  15. // @grant GM_deleteValue
  16. // @grant GM_addStyle
  17. // @run-at context-menu
  18. // @grant GM_registerMenuCommand
  19. // @grant GM_setClipboard
  20. // @grant GM_log
  21. // @compatible firefox
  22. // @compatible chrome
  23. // @compatible edge
  24. // @icon http://minhill.com/blog/wp-content/uploads/2012/03/favicon.ico
  25. // @note 2016/11/22 改写的第一个版本,存在BUG:无法正确选取图像
  26. // ==/UserScript==
  27.  
  28. var snapLinks = {
  29. timer: null,
  30. button: 0,
  31.  
  32. init: function() {
  33. /*if (!snapLinks.inited) {
  34. var menuitem = document.getElementById("SnapLinksCopyLinksSetFormat");
  35. if (menuitem) {
  36. var func = function() {
  37. var format = prompt('请输入需要设置的格式(%t:标题,%u:链接,%n:序号,%r:反向序号)',
  38. '<a href="%u">%r. %t</a><br>');
  39. snapLinks.copyLinks(null, false, format);
  40. };
  41. menuitem.addEventListener('command', func, false);
  42. }
  43.  
  44. snapLinks.inited = true;
  45. }*/
  46.  
  47.  
  48. this.win = window;
  49. if (snapLinks.win == window) snapLinks.win = window;
  50. this.doc = this.win.document;
  51. this.body = this.doc.body;
  52. if (!this.body instanceof HTMLBodyElement){
  53. alert("Can not snaplinks.");
  54. return false;
  55. }
  56.  
  57. this.root = snapLinks.doc.documentElement;
  58. //this.utils = this.win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
  59. this.popup = document.getElementById("snapLinksMenupopup");
  60.  
  61. this.bodyCursor = this.body.style.cursor;
  62. this.rootCursor = this.root.style.cursor;
  63. this.body.style.setProperty("cursor", "crosshair", "important");
  64. this.root.style.setProperty("cursor", "crosshair", "important");
  65.  
  66. this.highlights = [];
  67. this.elements = [];
  68.  
  69.  
  70. this.doc.addEventListener("mousedown", snapLinks.handleEvent, true);
  71. this.doc.addEventListener("pagehide", snapLinks.handleEvent, true);
  72. },
  73. uninit: function() {
  74.  
  75. snapLinks.doc.removeEventListener("mousedown", snapLinks.handleEvent, true);
  76. snapLinks.doc.removeEventListener("mousemove", snapLinks.handleEvent, true);
  77. snapLinks.doc.removeEventListener("pagehide", snapLinks.handleEvent, true);
  78. snapLinks.doc.removeEventListener("mouseup", snapLinks.handleEvent, true);//?
  79. setTimeout(function(self){
  80. snapLinks.doc.removeEventListener("click", snapLinks.handleEvent, true);
  81. }, 10, snapLinks);
  82.  
  83. if (snapLinks.box && snapLinks.box.parentNode)
  84. snapLinks.box.parentNode.removeChild(snapLinks.box);
  85. snapLinks.box = null;
  86. snapLinks.body.style.cursor = snapLinks.bodyCursor;
  87. snapLinks.root.style.cursor = snapLinks.rootCursor;
  88. },
  89. destroy: function() {
  90. snapLinks.uninit();
  91. snapLinks.lowlightAll();
  92. document.removeEventListener("click",snapLinks.destroy,false);
  93.  
  94. var sslpop = document.getElementById("snapLinksMenupopup")
  95. sslpop.setAttribute("class","hidden_popup");
  96. sslpop.setAttribute("style",null);
  97.  
  98. },
  99. handleEvent: function(event) {
  100.  
  101. switch(event.type){
  102. case "mousedown":
  103. if (event.button != 0 || event.ctrlKey || event.shiftKey || event.altKey) return;
  104. event.preventDefault();
  105. event.stopPropagation();
  106.  
  107. snapLinks.draw(event);
  108. break;
  109. case "mousemove":
  110. event.preventDefault();
  111. event.stopPropagation();
  112. var moveX = event.pageX;
  113. var moveY = event.pageY;
  114. if (snapLinks.downX > moveX) snapLinks.box.style.left = moveX + "px";
  115. if (snapLinks.downY > moveY) snapLinks.box.style.top = moveY + "px";
  116. snapLinks.box.style.width = Math.abs(moveX - snapLinks.downX) + "px";
  117. snapLinks.box.style.height = Math.abs(moveY - snapLinks.downY) + "px";
  118.  
  119. if (snapLinks.timer) {
  120. clearTimeout(snapLinks.timer);
  121. snapLinks.timer = null;
  122. }
  123. var timeStamp = new Date().getTime();
  124. if (timeStamp - snapLinks.lastHiglightedTime > 150) {
  125. snapLinks.boxRect = snapLinks.box.getBoundingClientRect();
  126. snapLinks.highlightAll();
  127. } else {
  128. var self = snapLinks;
  129. snapLinks.timer = setTimeout(function() {
  130. self.boxRect = self.box.getBoundingClientRect();
  131. self.highlightAll();
  132. }, 200);
  133. }
  134. break;
  135. case "mouseup":
  136.  
  137. if (event.button != snapLinks.button || event.ctrlKey || event.shiftKey) return;
  138. event.preventDefault();
  139. event.stopPropagation();
  140.  
  141. if (snapLinks.timer) {
  142. clearTimeout(snapLinks.timer);
  143. snapLinks.timer = null;
  144. }
  145. snapLinks.boxRect = snapLinks.box.getBoundingClientRect();
  146. snapLinks.highlightAll();
  147.  
  148.  
  149.  
  150.  
  151. for (let e of snapLinks.highlights) {
  152. if (e instanceof HTMLImageElement) {
  153. let link = snapLinks.doc.evaluate(
  154. 'ancestor::*[@href]', e, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  155. if (snapLinks.highlights.indexOf(link) === -1) {
  156. snapLinks.elements[snapLinks.elements.length] = link;
  157. }
  158. continue;
  159. }
  160. snapLinks.elements[snapLinks.elements.length] = e;
  161. }
  162. snapLinks.elements = snapLinks.elements;//?
  163.  
  164. snapLinks.uninit();
  165. snapLinks.showPopup(event);
  166. break;
  167. case "click":
  168. event.preventDefault();
  169. event.stopPropagation();
  170. break;
  171. case "pagehide":
  172. snapLinks.destroy();
  173. break;
  174. }
  175. },
  176. draw: function(aEvent) {
  177. this.lastHiglightedTime = new Date().getTime();
  178. this.downX = aEvent.pageX;
  179. this.downY = aEvent.pageY;
  180. this.box = this.doc.createElement("div");
  181. this.box.id = "snap-links-box";
  182. this.box.style.cssText = [
  183. 'background-color: rgba(0,128,255,.1) !important;',
  184. 'border: 1px solid rgb(255,255,0) !important;',
  185. 'box-sizing: border-box !important;',
  186. '-moz-box-sizing: border-box !important;',
  187. 'position: absolute !important;',
  188. 'z-index: 2147483647 !important;',
  189. 'top:' + this.downY + 'px;',
  190. 'left:' + this.downX + 'px;',
  191. 'cursor: crosshair !important;',
  192. 'margin: 0px !important;',
  193. 'padding: 0px !important;',
  194. 'outline: none !important;',
  195. ].join(" ");
  196. this.body.appendChild(this.box);
  197.  
  198. this.doc.removeEventListener("mousedown", this.handleEvent, true);
  199. this.doc.addEventListener("mousemove", this.handleEvent, true);
  200. this.doc.addEventListener("mouseup", this.handleEvent, true);
  201. this.doc.addEventListener("click", this.handleEvent, true);
  202. },
  203. highlightAll: function() {
  204. var a = '[href]:not([href^="javascript:"]):not([href^="mailto:"]):not([href^="#"])';
  205. var selector = a + ', ' + a + ' img, input[type="checkbox"], input[type="radio"]';
  206. selector += ', a.b-in-blk.input-cbx[href^="javascript:"]'; // 百度盘的特殊多选框
  207.  
  208. var contains = this.getContainsElements();
  209. contains.reverse();
  210. var matches = [];
  211. for (let e of contains) {
  212. if (e.nodeType !== 1 || !e.matches(selector))
  213. continue;
  214.  
  215. if (e.hasAttribute('href')) {
  216. let imgs = Array.prototype.slice.call(e.getElementsByTagName('img'));
  217. if (imgs[0]) {
  218. [].push.apply(contains, imgs);
  219. continue;
  220. }
  221. }
  222.  
  223. if (!("defStyle" in e))
  224. this.highlight(e);
  225. matches[matches.length] = e;
  226. }
  227.  
  228. this.highlights.forEach(function(e, i, a){
  229. if (matches.indexOf(e) === -1)
  230. this.lowlight(e);
  231. }, this);
  232.  
  233. this.highlights = matches;
  234. this.lastHiglightedTime = new Date().getTime();
  235. },
  236. lowlightAll: function() {
  237. this.highlights.forEach(function(e){
  238. this.lowlight(e);
  239. }, this);
  240. },
  241. highlight: function(elem) {
  242. if (!('defStyle' in elem))
  243. elem.defStyle = elem.getAttribute('style');
  244. //elem.style.setProperty('outline', '2px solid #ff0000', 'important');
  245. elem.style.setProperty('outline', '2px solid #ff0000', null);
  246. elem.style.setProperty('outline-offset', '-1px', null);
  247. //elem.style.setProperty('outline-offset', '-1px', 'important');
  248. },
  249. lowlight: function(elem) {
  250. if ("defStyle" in elem) {
  251. elem.defStyle?
  252. elem.style.cssText = elem.defStyle:
  253. elem.removeAttribute("style");
  254. delete elem.defStyle;
  255. }
  256. },
  257. getContainsElements: function() {
  258. if (!this.boxRect) return;
  259. var a = '[href]:not([href^="javascript:"]):not([href^="mailto:"]):not([href^="#"])';
  260. var selector = a + ', ' + a + ' img, input[type="checkbox"], input[type="radio"]';
  261. selector += ', a.b-in-blk.input-cbx[href^="javascript:"]';
  262. //var nodes = document.querySelectorAll("a[href],img,radio,checkbox");
  263. var nodes = document.querySelectorAll(selector);
  264. var arraynode=[] , len = nodes.length , i;
  265.  
  266.  
  267.  
  268. for (i = 0; i < len; i++) {
  269. if(this.inSelect(nodes[i])) arraynode.push(nodes[i]);
  270. }
  271.  
  272. return arraynode;
  273.  
  274. },
  275.  
  276. inSelect : function (node){
  277. var boxPos = snapLinks.boxRect;
  278. var xmin = boxPos.left, xmax = boxPos.right, ymin = boxPos.top, ymax = boxPos.bottom;
  279.  
  280. var pos = this.getOffset(node);
  281. var point = new Array();
  282.  
  283. point = [pos.x, pos.x + pos.width, pos.y, pos.y + pos.height];
  284.  
  285. var swithcase = [];
  286. if((point[0]>xmin&&point[0]<xmax)||
  287. (point[1]>xmin&&point[1]<xmax)||
  288. (point[0]<xmin&&point[1]>xmax)){
  289. swithcase[0] = true;
  290. }
  291. if((point[2]>ymin&&point[2]<ymax)||
  292. (point[3]>ymin&&point[3]<ymax)||
  293. (point[2]<ymin&&point[3]>ymax)){
  294. swithcase[1] = true;
  295. }
  296.  
  297. if(swithcase[0]&&swithcase[1]){
  298. return true;
  299. }
  300.  
  301. else{
  302. return false;
  303. }
  304.  
  305. },
  306.  
  307. getOffset : function(node){
  308. var rect = node.getBoundingClientRect();
  309.  
  310. return {
  311. //x: window.pageXOffset + rect.left,
  312. //y: window.pageYOffset + rect.top,
  313. x: rect.left,
  314. y: rect.top,
  315. width: rect.width,
  316. height: rect.height
  317. };
  318. },
  319.  
  320.  
  321. showPopup: function(aEvent) {
  322.  
  323. var cls = [];
  324.  
  325. var linkcount = 0;
  326. var specialLinkCount = 0; // 特殊的类似多选框的链接
  327. var imagecount = 0;
  328. var checkboxcount = 0;
  329. var radiocount = 0;
  330. for (let elem of this.elements) {
  331. if (elem instanceof HTMLAnchorElement)
  332. elem.href.indexOf('javascript:') == 0 ? specialLinkCount++ : linkcount++;
  333. }
  334. for (let elem of this.elements) {
  335. if (elem instanceof HTMLAnchorElement && /\.(jpe?g|png|gif|bmp)$/i.test(elem.href))
  336. imagecount++;
  337. }
  338. for (let elem of this.elements) {
  339. if (elem instanceof HTMLInputElement && elem.type === 'checkbox') {
  340. checkboxcount++;
  341. }
  342. }
  343. for (let elem of this.elements) {
  344. if (elem instanceof HTMLInputElement && elem.type === 'radio') {
  345. radiocount++;
  346. }
  347. }
  348. if ( linkcount > 0 ) cls.push("hasLink");
  349. if ( imagecount > 0 ) cls.push("hasImageLink");
  350. if ( checkboxcount > 0 ) cls.push("hasCheckbox");
  351. if ( radiocount > 0 ) cls.push("hasRadio");
  352. if ( specialLinkCount > 0 ) cls.push("hasSpecialLink");
  353.  
  354.  
  355.  
  356. var setCount = function(id, label){
  357. let currentEntry = document.getElementById(id);
  358. if(currentEntry)
  359. currentEntry.innerHTML = label;
  360. };
  361.  
  362. var data = {
  363. "SnapLinksOpenLinks": "在新标签打开所有链接 (" + linkcount + ")",
  364. "SnapLinksCopyLinks": "复制所有链接URL (" + linkcount + ")",
  365. "SnapLinksCopyLinksReverse": "复制所有链接URL (" + linkcount + ") (反向)",
  366. "SnapLinksCopyLinksAndTitles": "复制所有链接标题 + URL (" + linkcount + ")",
  367. "SnapLinksCopyLinksAndTitlesMD": "复制所有链接标题 + URL (" + linkcount + ") (MD)",
  368. "SnapLinksCopyLinksAndTitlesBBS": "复制所有链接标题 + URL (" + linkcount + ") (BBS)",
  369. "SnapLinksCopyLinksRegExp": "复制所有链接标题 + URL (" + linkcount + ") (筛选)",
  370. "SnapLinksCopyLinksSetFormat": "复制所有链接标题 + URL (" + linkcount + ") (设置复制格式)",
  371. "SnapLinksOpenImageLinks": "在新标签页打开所有图片链接 (" + imagecount + ")",
  372. "SnapLinksImageLinksOnePage": "在一个标签页显示所有图片链接 (" + imagecount + ")",
  373. "SnapLinksCheckBoxSelect": "复选框 - 选中 (" + checkboxcount + ")",
  374. "SnapLinksCheckBoxCancel": "复选框 - 取消 (" + checkboxcount + ")",
  375. "SnapLinksCheckBoxTaggle": "复选框 - 反选 (" + checkboxcount + ")",
  376. "SnapLinksRadioSelect": "单选框 - 选中 (" + radiocount + ")",
  377. "SnapLinksRadioCancel": "单选框 - 取消 (" + radiocount + ")",
  378. "SnapLinksClickLinks": "特殊单选框 - 选中 (" + specialLinkCount + ")",
  379. };
  380.  
  381. for(let id in data){
  382. setCount(id, data[id]);
  383. }
  384.  
  385.  
  386. var setStyleNode = function(showList){
  387. var setList = ["hasLink","hasImageLink","hasCheckbox","hasRadio","hasSpecialLink"];
  388. setList.forEach(
  389. function(elist){
  390. eClass = document.getElementsByClassName(elist);
  391. if(eClass){
  392. if(showList.indexOf(elist)==-1){
  393. for(var i=0;i<eClass.length;i++){
  394. eClass[i].style = "display:none";
  395. }
  396. //eClass.forEach(function(enode){enode.setAttribute("stlye","display:none")})
  397. } else{
  398. for(var i=0;i<eClass.length;i++){
  399. eClass[i].style = "display:block";
  400. }
  401. //eClass.forEach(function(enode){enode.setAttribute("stlye","display:block")})
  402. }
  403. }
  404. }
  405. )
  406. }
  407.  
  408.  
  409.  
  410.  
  411. if (cls.length > 0) {
  412. setStyleNode(cls);
  413. this.openPopupAtScreen(aEvent.pageX, aEvent.pageY,aEvent.clientX,aEvent.clientY);
  414.  
  415. //snapLinks.popup.className = cls.join(' ');
  416.  
  417. } else {
  418. this.lowlightAll();
  419. }
  420. },
  421. openPopupAtScreen:function(ax,ay,cx,cy){
  422.  
  423. var popMenu = document.getElementById("snapLinksMenupopup");
  424. var midx = document.documentElement.clientWidth/2;
  425. var midy = document.documentElement.clientHeight/2;
  426. //GM_log("pointerY:"+ay);
  427. //GM_log("screen:"+midy*2);
  428.  
  429.  
  430.  
  431. popMenu.className = "trigger_popup";
  432. //popMenu.style.position = "absolute";
  433.  
  434. var menuRight = ax - popMenu.clientWidth;
  435.  
  436. var menuDown = ay - popMenu.clientHeight;
  437.  
  438. document.addEventListener("click",snapLinks.destroy,false);
  439.  
  440. xaxis = (cx<midx) ? "left: "+ax.toString()+"px;":"left: "+menuRight.toString()+"px;";
  441.  
  442. yaxis = (cy<midy) ? " top: "+ay.toString()+"px;" : " top: "+menuDown.toString()+"px;";
  443. popMenu.setAttribute("style", xaxis + yaxis);
  444.  
  445.  
  446.  
  447. },
  448. openLinks : function(regexp){
  449. var obj = {};
  450. for (let elem of this.elements) {
  451. if (!elem.href || /^(?:javascript:|mailto:|#)/i.test(elem.href)) continue;
  452. if (!regexp || regexp.test(elem.href))
  453. obj[elem.href] = true;
  454. }
  455. for (let [key, val] of Object.entries(obj)) {
  456.  
  457. GM_openInTab(key);
  458. //gBrowser.addTab(key, { ownerTab: gBrowser.mCurrentTab });
  459. }
  460. },
  461. clickLinks : function(){
  462. for (let elem of this.elements) {
  463. if (!elem.href || /^(?:javascript:|mailto:|#)/i.test(elem.href)) {
  464. elem.click();
  465. }
  466. }
  467. },
  468. copyLinks : function(regexp, reverse, format){
  469.  
  470.  
  471.  
  472.  
  473. //GM_log(selements);
  474. var links = this.elements.filter(function(elem){
  475. return elem instanceof HTMLAnchorElement && (!regexp || regexp.test(elem.href))
  476. });
  477.  
  478. var num = 1,
  479. numReverse = links.length;
  480. links = links.map(function(e) {
  481. if (format) {
  482. return format.replace(/%t/g, e.textContent)
  483. .replace(/%u/g, e.href)
  484. .replace(/%r/g, numReverse--)
  485. .replace(/%n/g, num++);
  486. }
  487. return e.href;
  488. });
  489.  
  490. // 筛选出重复的
  491. links = snapLinks.unique(links);
  492.  
  493. if(reverse)
  494. links = links.reverse();
  495.  
  496. if (links.length){
  497. GM_setClipboard(links.join('\n'));
  498. //Components.classes["@mozilla.org/widget/clipboardhelper;1"]
  499. // .getService(Components.interfaces.nsIClipboardHelper)
  500. // .copyString(links.join('\n'));
  501. }
  502. },
  503. imageOnePage : function(){
  504. var htmlsrc = [
  505. '<style>'
  506. ,'img { max-width: 100%; max-height: 100%; }'
  507. ,'</style>'].join('');
  508. for (let elem of this.elements) {
  509. if (elem instanceof HTMLAnchorElement && /\.(jpe?g|png|gif|bmp)$/i.test(elem.href))
  510. htmlsrc += '\n<img src="' + elem.href + '">'
  511. }
  512. GM_openInTab("data:text/html;charset=utf-8," +
  513. '<html><head><title>' + snapLinks.doc.domain + ' 图象列表</title><body>' +
  514. encodeURIComponent(htmlsrc));
  515. },
  516. checkbox : function(bool){
  517. for (let elem of this.elements) {
  518. if (elem instanceof HTMLInputElement && elem.type === 'checkbox') {
  519. elem.checked = arguments.length == 0?
  520. !elem.checked :
  521. bool;
  522. }
  523. }
  524. },
  525. radio : function(bool){
  526. for (let elem of this.elements) {
  527. if (elem instanceof HTMLInputElement && elem.type === 'radio') {
  528. elem.checked = arguments.length == 0?
  529. !elem.checked :
  530. bool;
  531. }
  532. }
  533. },
  534. unique: function(a){
  535. var o = {},
  536. r = [],
  537. t;
  538. for (var i = 0, l = a.length; i < l; i++) {
  539. t = a[i];
  540. if(!o[t]){
  541. o[t] = true;
  542. r.push(t);
  543. }
  544. }
  545. return r;
  546. }
  547. };
  548.  
  549.  
  550.  
  551.  
  552.  
  553. function begin() {
  554. var ibody = document.getElementsByTagName("body")[0];
  555. /* ibody.setAttribute("contextmenu","popup-menu");
  556.  
  557. var rclickMenu = document.createElement("menu");
  558. rclickMenu.setAttribute("type","context");
  559. rclickMenu.setAttribute('id', "popup-menu");
  560.  
  561. var imenu = document.createElement("menuitem");
  562. imenu.setAttribute("id","snapclicks");
  563. imenu.setAttribute('label', "snap-links 🐔");
  564. imenu.setAttribute("image","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAALUlEQVQ4jWNgkEv8TxHGJ/nr18//v379HDWALgbAFJKKqWfAwIfBqAF4JInAAIZN/GgepyNAAAAAAElFTkSuQmCC");
  565. //imenu.innerHTML = "snap links,,Ծ‸Ծ,, ";
  566.  
  567. rclickMenu.appendChild(imenu);
  568. ibody.appendChild(rclickMenu);
  569.  
  570. imenu.addEventListener("click", function(){snapLinks.init();}, false); */
  571.  
  572. var popup = document.createElement("div");
  573. //popup.setAttribute("onclick","snapLinks.lowlightAll();");
  574. popup.setAttribute("id","snapLinksMenupopup");
  575. popup.setAttribute("class","hidden_popup");
  576. popup.innerHTML = '<div class = "-hasLink-">' +
  577. '<div id="SnapLinksOpenLinks" class="hasLink" >在新标签打开所有链接</div>' +
  578. '<div id="SnapLinksCopyLinks" class="hasLink" >复制所有链接URL</div>' +
  579. '<div id="SnapLinksCopyLinksReverse" class="hasLink" >复制所有链接URL(反向)</div>' +
  580. '<div id="SnapLinksCopyLinksAndTitles" class="hasLink" >复制所有链接标题 + URL</div>' +
  581. '<div id="SnapLinksCopyLinksAndTitlesMD" class="hasLink" >复制所有链接标题 + URL (MD)</div>' +
  582. '<div id="SnapLinksCopyLinksAndTitlesBBS" class="hasLink">复制所有链接标题 + URL (BBS)</div>' +
  583. '<div id="SnapLinksCopyLinksRegExp" class="hasLink" >复制所有链接标题 + URL (筛选)</div>' +
  584. '<div id="SnapLinksCopyLinksSetFormat" class="hasLink" >复制所有链接标题 + URL (设置复制格式)</div>' +
  585. '<div id="SnapLinksOpenImageLinks" class="hasImageLink" >在新标签页打开所有图片链接</div>' +
  586. '<div id="SnapLinksImageLinksOnePage" class="hasImageLink" >在一个标签页显示所有图片链接</div>' +
  587. '</div>' +
  588. '<div class="hasLink-hasCheckbox-hasRadio" >' +
  589. '<div id="SnapLinksCheckBoxSelect" class="hasCheckbox" >复选框 - 选中</div>' +
  590. '<div id="SnapLinksCheckBoxCancel" class="hasCheckbox" >复选框 - 取消</div>' +
  591. '<div id="SnapLinksCheckBoxTaggle" class="hasCheckbox" >复选框 - 反选</div>' +
  592. '<div id="SnapLinksRadioSelect" class="hasRadio" >单选框 - 选中</div>' +
  593. '<div id="SnapLinksRadioCancel" class="hasRadio">单选框 - 取消</div>' +
  594. '<div id="SnapLinksClickLinks" class="hasSpecialLink" >特殊单选框 - 选中</div>' +
  595. '</div>';
  596. ibody.appendChild(popup);
  597.  
  598.  
  599.  
  600. //popup.addEventListener("click",function(){snapLinks.lowlightAll()},false);
  601. document.getElementById("SnapLinksOpenLinks").addEventListener("click",function(){snapLinks.openLinks();}, false);
  602. document.getElementById("SnapLinksCopyLinks").addEventListener("click",function(){snapLinks.copyLinks();},false);
  603. document.getElementById("SnapLinksCopyLinksReverse").addEventListener("click",function(){snapLinks.copyLinks(null, true);},false);
  604. document.getElementById("SnapLinksCopyLinksAndTitles").addEventListener("click",function(){snapLinks.copyLinks(null, false, '%t\n%u');},false);
  605. document.getElementById("SnapLinksCopyLinksAndTitlesMD").addEventListener("click",function(){snapLinks.copyLinks(null, false, '[%t](%u)');},false);
  606. document.getElementById("SnapLinksCopyLinksAndTitlesBBS").addEventListener("click",function(){snapLinks.copyLinks(null, false, '[url=%u]%t[/url]');},false);
  607. document.getElementById("SnapLinksCopyLinksRegExp").addEventListener("click",function(){var reg=prompt('请输入需要筛选的 RegExp', '');snapLinks.copyLinks(new RegExp(reg));},false);
  608. //document.getElementById("SnapLinksCopyLinksSetFormat").addEventListener("click",function(){snapLinks.copyLinks()},false);
  609.  
  610. document.getElementById("SnapLinksOpenImageLinks").addEventListener("click",function(){snapLinks.openLinks(/\.(jpe?g|png|gif|bmp)$/i);},false);
  611. document.getElementById("SnapLinksImageLinksOnePage").addEventListener("click",function(){snapLinks.imageOnePage();},false);
  612. document.getElementById("SnapLinksCheckBoxSelect").addEventListener("click",function(){snapLinks.checkbox(true);},false);
  613. document.getElementById("SnapLinksCheckBoxCancel").addEventListener("click",function(){snapLinks.checkbox(false);},false);
  614. document.getElementById("SnapLinksCheckBoxTaggle").addEventListener("click",function(){snapLinks.checkbox();},false);
  615. document.getElementById("SnapLinksRadioSelect").addEventListener("click",function(){snapLinks.radio(true);},false);
  616. document.getElementById("SnapLinksRadioCancel").addEventListener("click",function(){snapLinks.radio(false);},false);
  617. document.getElementById("SnapLinksClickLinks").addEventListener("click",function(){snapLinks.clickLinks();},false);
  618.  
  619. GM_addStyle(".hidden_popup { display:none!important; } .trigger_popup{display:block!important;z-index:99999}" +
  620.  
  621. " #snapLinksMenupopup{position:absolute;background-color: rgb(45,53,63);border-bottom: 0px solid rgb(20,20,20); padding:5px;" +
  622. "border-bottom: 0px solid rgb(20,20,20);cursor:pointer;border-radius: 4px;border: 1px solid rgb(22,25,28);box-shadow:0 1px 0 rgba(162,184,204,0.25) inset,0 0 4px hsla(0,0%,0%,0.95);}" +
  623. "#snapLinksMenupopup div{color: white;} #snapLinksMenupopup > div > div:hover{color: rgb(51,159,255);" +
  624. "background-color: transparent; background-image:linear-gradient(to bottom,rgb(37,46,54),rgb(36,40,45));} ");
  625. }
  626.  
  627. begin();
  628. snapLinks.init();
  629.