怠惰小说下载器

通用网站内容抓取工具,可批量抓取任意站点的小说、论坛内容等并保存为TXT文档

当前为 2023-10-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DownloadAllContent
  3. // @name:zh-CN 怠惰小说下载器
  4. // @name:zh-TW 怠惰小説下載器
  5. // @name:ja 怠惰者小説ダウンロードツール
  6. // @namespace hoothin
  7. // @version 2.7.4.1
  8. // @description Fetch and download main content on current page, provide special support for novel
  9. // @description:zh-CN 通用网站内容抓取工具,可批量抓取任意站点的小说、论坛内容等并保存为TXT文档
  10. // @description:zh-TW 通用網站內容抓取工具,可批量抓取任意站點的小說、論壇內容等並保存為TXT文檔
  11. // @description:ja ユニバーサルサイトコンテンツクロールツール、クロール、フォーラム内容など
  12. // @author hoothin
  13. // @match http://*/*
  14. // @match https://*/*
  15. // @match ftp://*/*
  16. // @grant GM_xmlhttpRequest
  17. // @grant GM_registerMenuCommand
  18. // @grant GM_setValue
  19. // @grant GM_getValue
  20. // @grant GM_openInTab
  21. // @grant GM_setClipboard
  22. // @grant unsafeWindow
  23. // @license MIT License
  24. // @compatible chrome
  25. // @compatible firefox
  26. // @compatible opera 未测试
  27. // @compatible safari 未测试
  28. // @contributionURL https://ko-fi.com/hoothin
  29. // @contributionAmount 1
  30. // ==/UserScript==
  31. (function (global, factory) {
  32. if (typeof define === "function" && define.amd) {
  33. define([], factory);
  34. } else if (typeof exports !== "undefined") {
  35. factory();
  36. } else {
  37. var mod = {
  38. exports: {}
  39. };
  40. factory();
  41. global.FileSaver = mod.exports;
  42. }
  43. })(this, function () {
  44. "use strict";
  45.  
  46. /*
  47. * FileSaver.js
  48. * A saveAs() FileSaver implementation.
  49. *
  50. * By Eli Grey, http://eligrey.com
  51. *
  52. * License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)
  53. * source : http://purl.eligrey.com/github/FileSaver.js
  54. */
  55. var _global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof global === 'object' && global.global === global ? global : void 0;
  56.  
  57. function bom(blob, opts) {
  58. if (typeof opts === 'undefined') opts = {
  59. autoBom: false
  60. };else if (typeof opts !== 'object') {
  61. console.warn('Deprecated: Expected third argument to be a object');
  62. opts = {
  63. autoBom: !opts
  64. };
  65. }
  66.  
  67. if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
  68. return new Blob([String.fromCharCode(0xFEFF), blob], {
  69. type: blob.type
  70. });
  71. }
  72.  
  73. return blob;
  74. }
  75.  
  76. function download(url, name, opts) {
  77. var xhr = new XMLHttpRequest();
  78. xhr.open('GET', url);
  79. xhr.responseType = 'blob';
  80.  
  81. xhr.onload = function () {
  82. saveAs(xhr.response, name, opts);
  83. };
  84.  
  85. xhr.onerror = function () {
  86. console.error('could not download file');
  87. };
  88.  
  89. xhr.send();
  90. }
  91.  
  92. function corsEnabled(url) {
  93. var xhr = new XMLHttpRequest();
  94.  
  95. xhr.open('HEAD', url, false);
  96.  
  97. try {
  98. xhr.send();
  99. } catch (e) {}
  100.  
  101. return xhr.status >= 200 && xhr.status <= 299;
  102. }
  103.  
  104.  
  105. function click(node) {
  106. try {
  107. node.dispatchEvent(new MouseEvent('click'));
  108. } catch (e) {
  109. var evt = document.createEvent('MouseEvents');
  110. evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
  111. node.dispatchEvent(evt);
  112. }
  113. }
  114.  
  115.  
  116. var isMacOSWebView = _global.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent);
  117. var saveAs = _global.saveAs || (
  118. typeof window !== 'object' || window !== _global ? function saveAs() {}
  119.  
  120. : 'download' in HTMLAnchorElement.prototype && !isMacOSWebView ? function saveAs(blob, name, opts) {
  121. var URL = _global.URL || _global.webkitURL;
  122. var a = document.createElement('a');
  123. name = name || blob.name || 'download';
  124. a.download = name;
  125. a.rel = 'noopener';
  126.  
  127. if (typeof blob === 'string') {
  128. a.href = blob;
  129.  
  130. if (a.origin !== location.origin) {
  131. corsEnabled(a.href) ? download(blob, name, opts) : click(a, a.target = '_blank');
  132. } else {
  133. click(a);
  134. }
  135. } else {
  136. a.href = URL.createObjectURL(blob);
  137. setTimeout(function () {
  138. URL.revokeObjectURL(a.href);
  139. }, 4E4);
  140.  
  141. setTimeout(function () {
  142. click(a);
  143. }, 0);
  144. }
  145. }
  146. : 'msSaveOrOpenBlob' in navigator ? function saveAs(blob, name, opts) {
  147. name = name || blob.name || 'download';
  148.  
  149. if (typeof blob === 'string') {
  150. if (corsEnabled(blob)) {
  151. download(blob, name, opts);
  152. } else {
  153. var a = document.createElement('a');
  154. a.href = blob;
  155. a.target = '_blank';
  156. setTimeout(function () {
  157. click(a);
  158. });
  159. }
  160. } else {
  161. navigator.msSaveOrOpenBlob(bom(blob, opts), name);
  162. }
  163. }
  164. : function saveAs(blob, name, opts, popup) {
  165. popup = popup || open('', '_blank');
  166.  
  167. if (popup) {
  168. popup.document.title = popup.document.body.innerText = 'downloading...';
  169. }
  170.  
  171. if (typeof blob === 'string') return download(blob, name, opts);
  172. var force = blob.type === 'application/octet-stream';
  173.  
  174. var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari;
  175.  
  176. var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
  177.  
  178. if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== 'undefined') {
  179. var reader = new FileReader();
  180.  
  181. reader.onloadend = function () {
  182. var url = reader.result;
  183. url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;');
  184. if (popup) popup.location.href = url;else location = url;
  185. popup = null;
  186. };
  187.  
  188. reader.readAsDataURL(blob);
  189. } else {
  190. var URL = _global.URL || _global.webkitURL;
  191. var url = URL.createObjectURL(blob);
  192. if (popup) popup.location = url;else location.href = url;
  193. popup = null;
  194.  
  195. setTimeout(function () {
  196. URL.revokeObjectURL(url);
  197. }, 4E4);
  198. }
  199. });
  200. _global.saveAs = saveAs.saveAs = saveAs;
  201.  
  202. if (typeof module !== 'undefined') {
  203. module.exports = saveAs;
  204. }
  205. });
  206.  
  207. (function() {
  208. 'use strict';
  209. var indexReg=/PART\b|^Prologue|Chapter\s*[\-_]?\d+|分卷|^序$|^序\s*言|^序\s*章|^前\s*言|^附\s*[录錄]|^引\s*[言子]|^摘\s*要|^[楔契]\s*子|^后\s*记|^後\s*記|^附\s*言|^结\s*语|^結\s*語|^尾\s*[声聲]|^最終話|^最终话|^番\s*外|^\d+[\s\.、,,)\-_::][^\d#\.]+$|^[第(]?[\d〇零一二三四五六七八九十百千万萬-]+\s*[、)章节節回卷折篇幕集话話]/i;
  210. var innerNextPage=/^\s*(下一[页頁张張]|next\s*page|次のページ)/i;
  211. var lang = navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
  212. var i18n={};
  213. var rCats=[];
  214. var processFunc;
  215. var win=(typeof unsafeWindow=='undefined'? window : unsafeWindow);
  216. switch (lang){
  217. case "zh-CN":
  218. case "zh-SG":
  219. i18n={
  220. fetch:"开始下载小说【Ctrl+F9】",
  221. info:"本文是使用怠惰小说下载器(DownloadAllContent)下载的",
  222. error:"该段内容获取失败",
  223. downloading:"已下载完成 %s 段,剩余 %s 段<br>正在下载 %s",
  224. complete:"已全部下载完成,共 %s 段",
  225. del:"设置文本干扰码的CSS选择器",
  226. custom:"自定规则下载",
  227. customInfo:"输入网址或者章节CSS选择器",
  228. reSort:"按标题名重新排序章节",
  229. reSortUrl:"按网址重新排序章节",
  230. setting:"选项参数设置",
  231. searchRule:"搜索网站规则",
  232. abort:"跳过此章",
  233. save:"保存当前",
  234. saveAsMd:"存为 Markdown",
  235. downThreadNum:"设置同时下载的线程数",
  236. customTitle:"自定义章节标题,输入内页文字对应选择器",
  237. reSortDefault:"默认按页面中位置排序章节",
  238. reverse:"反转章节排序",
  239. saveBtn:"保存设置",
  240. saveOk:"保存成功"
  241. };
  242. break;
  243. case "zh-TW":
  244. case "zh-HK":
  245. i18n={
  246. fetch:"開始下載小說【Ctrl+F9】",
  247. info:"本文是使用怠惰小說下載器(DownloadAllContent)下載的",
  248. error:"該段內容獲取失敗",
  249. downloading:"已下載完成 %s 段,剩餘 %s 段<br>正在下載 %s",
  250. complete:"已全部下載完成,共 %s 段",
  251. del:"設置文本干擾碼的CSS選擇器",
  252. custom:"自訂規則下載",
  253. customInfo:"輸入網址或者章節CSS選擇器",
  254. reSort:"按標題名重新排序章節",
  255. reSortUrl:"按網址重新排序章節",
  256. setting:"選項參數設定",
  257. searchRule:"搜尋網站規則",
  258. abort:"跳過此章",
  259. save:"保存當前",
  260. saveAsMd:"存爲 Markdown",
  261. downThreadNum:"設置同時下載的綫程數",
  262. customTitle:"自訂章節標題,輸入內頁文字對應選擇器",
  263. reSortDefault:"預設依頁面中位置排序章節",
  264. reverse:"反轉章節排序",
  265. saveBtn:"儲存設定",
  266. saveOk:"儲存成功"
  267. };
  268. break;
  269. default:
  270. i18n={
  271. fetch:"Download [Ctrl+F9]",
  272. info:"The TXT is downloaded by 'DownloadAllContent'",
  273. error:"Failed in downloading current chapter",
  274. downloading:"%s pages are downloaded, there are still %s pages left<br>Downloading %s ......",
  275. complete:"Completed! Get %s pages in total",
  276. del:"Set css selectors for ignore",
  277. custom:"Custom to download",
  278. customInfo:"Input urls OR sss selectors for chapter links",
  279. reSort:"ReSort by title",
  280. reSortUrl:"Resort by URLs",
  281. setting:"Open Setting",
  282. searchRule:"Search rule",
  283. abort:"Abort",
  284. save:"Save",
  285. saveAsMd:"Save as Markdown",
  286. downThreadNum:"Set threadNum for download",
  287. customTitle: "Customize the chapter title, enter the selector on inner page",
  288. reSortDefault: "Default sort by position in the page",
  289. reverse:"Reverse chapter ordering",
  290. saveBtn:"Save Setting",
  291. saveOk:"Save Over"
  292. };
  293. break;
  294. }
  295. var firefox=navigator.userAgent.toLowerCase().indexOf('firefox')!=-1,curRequests=[];
  296. var rocketContent,txtDownContent,txtDownWords,txtDownQuit,txtDownDivInited=false;
  297.  
  298. function initTxtDownDiv(){
  299. if(txtDownDivInited)return;
  300. txtDownDivInited=true;
  301. rocketContent=document.createElement("div");
  302. document.body.appendChild(rocketContent);
  303. rocketContent.outerHTML=`
  304. <div id="txtDownContent">
  305. <div style="font-size:16px;color:#333333;width:362px;height:110px;position:fixed;left:50%;top:50%;margin-top:-25px;margin-left:-150px;z-index:100000;background-color:#ffffff;border:1px solid #afb3b6;border-radius:10px;opacity:0.95;filter:alpha(opacity=95);box-shadow:5px 5px 20px 0px #000;">
  306. <div id="txtDownWords" style="position:absolute;width:275px;height: 90px;max-height: 90%;border: 1px solid #f3f1f1;padding: 8px;border-radius: 10px;overflow: auto;">
  307. Analysing......
  308. </div>
  309. <div id="txtDownQuit" style="width: 30px;height: 30px;border-radius: 30px;position:absolute;right:2px;top:2px;cursor: pointer;background-color:#ff5a5a;">
  310. <span style="height: 30px;line-height: 30px;display:block;color:#FFF;text-align:center;font-size: 12px;font-weight: bold;font-family: arial;background: initial; float: initial;">╳</span>
  311. </div>
  312. <div style="position:absolute;right:0px;bottom:2px;cursor: pointer;max-width:85px">
  313. <button id="abortRequest" style="background: #008aff;border: 0;padding: 5px;border-radius: 6px;color: white;float: right;margin: 1px;height: 25px;display:none;line-height: 16px;">${getI18n('abort')}</button>
  314. <button id="tempSaveTxt" style="background: #008aff;border: 0;padding: 5px;border-radius: 6px;color: white;float: right;margin: 1px;height: 25px;line-height: 16px;cursor: pointer;">${getI18n('save')}</button>
  315. <button id="saveAsMd" style="background: #008aff;border: 0;padding: 5px;border-radius: 6px;color: white;float: right;margin: 1px;height: 25px;line-height: 16px;cursor: pointer;overflow: hidden;" title="${getI18n('saveAsMd')}">Markdown</button>
  316. </div>
  317. </div>
  318. </div>`;
  319. txtDownContent=document.querySelector("#txtDownContent");
  320. txtDownWords=document.querySelector("#txtDownWords");
  321. txtDownQuit=document.querySelector("#txtDownQuit");
  322. txtDownQuit.onclick=function(){
  323. txtDownContent.style.display="none";
  324. txtDownContent.parentNode.removeChild(txtDownContent);
  325. };
  326. initTempSave();
  327. }
  328.  
  329. function saveContent() {
  330. if (win.downloadAllContentSaveAsZip) {
  331. win.downloadAllContentSaveAsZip(rCats, i18n.info, content => {
  332. saveAs(content, document.title + ".zip");
  333. });
  334. } else {
  335. var blob = new Blob([i18n.info + "\r\n\r\n" + document.title + "\r\n\r\n" + rCats.join("\r\n\r\n")], {type: "text/plain;charset=utf-8"});
  336. saveAs(blob, document.title + ".txt");
  337. }
  338. }
  339.  
  340. function initTempSave(){
  341. var tempSavebtn = document.getElementById('tempSaveTxt');
  342. var abortbtn = document.getElementById('abortRequest');
  343. var saveAsMd = document.getElementById('saveAsMd');
  344. tempSavebtn.onclick = function(){
  345. saveContent();
  346. console.log(curRequests);
  347. }
  348. abortbtn.onclick = function(){
  349. let curRequest = curRequests.pop();
  350. if(curRequest)curRequest[1].abort();
  351. }
  352. saveAsMd.onclick = function(){
  353. let txt = i18n.info+"\n\n---\n"+document.title+"\n===\n";
  354. rCats.forEach(cat => {
  355. cat = cat.replace("\r\n", "\n---").replace(/(\r\n|\n\r)+/g, "\n\n").replace(/[\n\r]\t+/g, "\n");
  356. txt += '\n\n'+cat;
  357. });
  358. var blob = new Blob([txt], {type: "text/plain;charset=utf-8"});
  359. saveAs(blob, document.title+".md");
  360. }
  361. }
  362.  
  363. function indexDownload(aEles){
  364. if(aEles.length<1)return;
  365. initTxtDownDiv();
  366. if(GM_getValue("contentSort")){
  367. aEles.sort(function(a,b){
  368. return parseInt(a.innerText.replace(/[^0-9]/ig,"")) - parseInt(b.innerText.replace(/[^0-9]/ig,""));
  369. });
  370. }
  371. if(GM_getValue("contentSortUrl")){
  372. aEles.sort(function(a,b){
  373. return parseInt(a.href.replace(/[^0-9]/ig,"")) - parseInt(b.href.replace(/[^0-9]/ig,""));
  374. });
  375. }
  376. if(GM_getValue("reverse")){
  377. aEles=aEles.reverse();
  378. }
  379. rCats=[];
  380. var customTitle=!!GM_getValue("customTitle");
  381. var insertSigns=[];
  382. // var j=0,rCats=[];
  383. var downIndex=0,downNum=0,downOnce=function(wait){
  384. if(downNum>=aEles.length)return;
  385. let curIndex=downIndex;
  386. let aTag=aEles[curIndex];
  387. let request=(aTag, curIndex)=>{
  388. let tryTimes=0;
  389. let requestBody={
  390. method: 'GET',
  391. url: aTag.href,
  392. headers:{
  393. referer:aTag.href,
  394. "Content-Type":"text/html;charset="+document.charset
  395. },
  396. timeout:15000,
  397. overrideMimeType:"text/html;charset="+document.charset,
  398. onload: function(result) {
  399. downIndex++;
  400. downNum++;
  401. let doc = getDocEle(result.responseText);
  402. let base = doc.querySelector("base");
  403. let nextPage=checkNextPage(doc, base ? base.href : aTag.href);
  404. if(nextPage){
  405. var inArr=false;
  406. for(var ai=0;ai<aEles.length;ai++){
  407. if(aEles[ai].href==nextPage.href){
  408. inArr=true;
  409. break;
  410. }
  411. }
  412. if(!inArr){
  413. nextPage.innerText=aTag.innerText+"\t>>";
  414. aEles.push(nextPage);
  415. let targetIndex = curIndex;
  416. for(let a=0;a<insertSigns.length;a++){
  417. let signs=insertSigns[a],breakSign=false;
  418. if(signs){
  419. for(let b=0;b<signs.length;b++){
  420. let sign=signs[b];
  421. if(sign==curIndex){
  422. targetIndex=a;
  423. breakSign=true;
  424. break;
  425. }
  426. }
  427. }
  428. if(breakSign)break;
  429. }
  430. let insertSign = insertSigns[targetIndex];
  431. if(!insertSign)insertSigns[targetIndex] = [];
  432. insertSigns[targetIndex].push(aEles.length-1);
  433. }
  434. }
  435. if (result.status >= 400) {
  436. console.warn("error:", `status: ${result.status} from: ${aTag.href}`);
  437. }
  438. if (customTitle) {
  439. try {
  440. let title = doc.querySelector(customTitle);
  441. if (title && title.innerText) {
  442. aTag.innerText = title.innerText;
  443. }
  444. } catch(e) {
  445. console.warn(e);
  446. }
  447. }
  448. processDoc(curIndex, aTag, doc, (result.status>=400?` status: ${result.status} from: ${aTag.href} `:""));
  449. if (wait) {
  450. setTimeout(() => {
  451. downOnce(wait);
  452. }, wait);
  453. } else downOnce();
  454. },
  455. onerror: function(e) {
  456. console.warn("error:", e);
  457. if(++tryTimes<3){
  458. return GM_xmlhttpRequest(requestBody);
  459. }
  460. downIndex++;
  461. downNum++;
  462. processDoc(curIndex, aTag, null, ` NETWORK ERROR: '+${(e.response||e.responseText)} from: ${aTag.href} `);
  463. if (wait) {
  464. setTimeout(() => {
  465. downOnce(wait);
  466. }, wait);
  467. } else downOnce();
  468. },
  469. ontimeout: function(e) {
  470. console.warn("timeout: times="+tryTimes+" url="+aTag.href);
  471. //console.log(e);
  472. if(++tryTimes<3){
  473. return GM_xmlhttpRequest(requestBody);
  474. }
  475. downIndex++;
  476. downNum++;
  477. processDoc(curIndex, aTag, null, ` TIMEOUT: '+${aTag.href} `);
  478. if (wait) {
  479. setTimeout(() => {
  480. downOnce(wait);
  481. }, wait);
  482. } else downOnce();
  483. }
  484. };
  485. return [curIndex, GM_xmlhttpRequest(requestBody), aTag.href];
  486. }
  487. if(!aTag){
  488. let waitAtagReadyInterval=setInterval(function(){
  489. if(downNum>=aEles.length)clearInterval(waitAtagReadyInterval);
  490. aTag=aEles[curIndex];
  491. if(aTag){
  492. clearInterval(waitAtagReadyInterval);
  493. request(aTag, curIndex);
  494. }
  495. },1000);
  496. return null;
  497. }
  498. let result = request(aTag, curIndex);
  499. if (result) curRequests.push(result);
  500. return result;
  501. };
  502. function getDocEle(str){
  503. var doc = null;
  504. try {
  505. doc = document.implementation.createHTMLDocument('');
  506. doc.documentElement.innerHTML = str;
  507. }
  508. catch (e) {
  509. console.log('parse error');
  510. }
  511. return doc;
  512. }
  513. function sortInnerPage(){
  514. var pageArrs=[],maxIndex=0,i,j;
  515. for(i=0;i<insertSigns.length;i++){
  516. var signs=insertSigns[i];
  517. if(signs){
  518. for(j=0;j<signs.length;j++){
  519. var sign=signs[j];
  520. var cat=rCats[sign];
  521. rCats[sign]=null;
  522. if(!pageArrs[i])pageArrs[i]=[];
  523. pageArrs[i].push(cat);
  524. }
  525. }
  526. }
  527. for(i=pageArrs.length-1;i>=0;i--){
  528. let pageArr=pageArrs[i];
  529. if(pageArr){
  530. for(j=pageArr.length-1;j>=0;j--){
  531. rCats.splice(i+1, 0, pageArr[j]);
  532. }
  533. }
  534. }
  535. rCats = rCats.filter(function(e){return e!=null});
  536. }
  537. var waitForComplete;
  538. function processDoc(i, aTag, doc, cause){
  539. let cbFunc=content=>{
  540. rCats[i]=(aTag.innerText.replace(/[\r\n\t]/g, "") + "\r\n" + (cause || '') + content.replace(/\s*$/, ""));
  541. curRequests = curRequests.filter(function(e){return e[0]!=i});
  542. txtDownContent.style.display="block";
  543. txtDownWords.innerHTML=getI18n("downloading",[downNum,(aEles.length-downNum),aTag.innerText]);
  544. if(downNum==aEles.length){
  545. if(waitForComplete) clearTimeout(waitForComplete);
  546. waitForComplete=setTimeout(()=>{
  547. if(downNum==aEles.length){
  548. txtDownWords.innerHTML=getI18n("complete",[downNum]);
  549. sortInnerPage();
  550. saveContent();
  551. }
  552. },3000);
  553. }
  554. };
  555. let contentResult=getPageContent(doc, content=>{
  556. cbFunc(content);
  557. });
  558. if(contentResult!==false){
  559. cbFunc(contentResult);
  560. }
  561. }
  562. var downThreadNum = parseInt(GM_getValue("downThreadNum"));
  563. downThreadNum = downThreadNum || 20;
  564. if (downThreadNum > 0) {
  565. for (var i = 0; i < downThreadNum; i++) {
  566. downOnce();
  567. if (downIndex >= aEles.length - 1 || downIndex >= downThreadNum - 1) break;
  568. else downIndex++;
  569. }
  570. } else {
  571. downOnce(-downThreadNum * 1000);
  572. if (downIndex < aEles.length - 1 && downIndex < downThreadNum - 1) downIndex++;
  573. }
  574.  
  575. /*for(let i=0;i<aEles.length;i++){
  576. let aTag=aEles[i];
  577. GM_xmlhttpRequest({
  578. method: 'GET',
  579. url: aTag.href,
  580. overrideMimeType:"text/html;charset="+document.charset,
  581. onload: function(result) {
  582. var doc = getDocEle(result.responseText);
  583. processDoc(i, aTag, doc);
  584. }
  585. });
  586. }*/
  587. }
  588.  
  589. function canonicalUri(src, baseUrl) {
  590. if (!src) {
  591. return "";
  592. }
  593. if (src.charAt(0) == "#") return baseUrl + src;
  594. if (src.charAt(0) == "?") return baseUrl.replace(/^([^\?#]+).*/, "$1" + src);
  595. let origin = location.protocol + '//' + location.host;
  596. let url = baseUrl || origin;
  597. url = url.replace(/(\?|#).*/, "");
  598. if (/https?:\/\/[^\/]+$/.test(url)) url = url + '/';
  599. if (url.indexOf("http") !== 0) url = origin + url;
  600. var root_page = /^[^\?#]*\//.exec(url)[0],
  601. root_domain = /^\w+\:\/\/\/?[^\/]+/.exec(root_page)[0],
  602. absolute_regex = /^\w+\:\/\//;
  603. while (src.indexOf("../") === 0) {
  604. src = src.substr(3);
  605. root_page = root_page.replace(/\/[^\/]+\/$/, "/");
  606. }
  607. src = src.replace(/\.\//, "");
  608. if (/^\/\/\/?/.test(src)) {
  609. src = location.protocol + src;
  610. }
  611. return (absolute_regex.test(src) ? src : ((src.charAt(0) == "/" ? root_domain : root_page) + src));
  612. }
  613.  
  614. function checkNextPage(doc, baseUrl){
  615. let aTags=doc.querySelectorAll("a"),nextPage=null;
  616. for(var i=0;i<aTags.length;i++){
  617. let aTag=aTags[i];
  618. if(innerNextPage.test(aTag.innerText) && aTag.href && !/javascript:|#/.test(aTag.href)){
  619. nextPage=aTag;
  620. nextPage.href=canonicalUri(nextPage.getAttribute("href"), baseUrl || location.href);
  621. break;
  622. }
  623. }
  624. return nextPage;
  625. }
  626.  
  627. function textNodesUnder(el){
  628. var n, a=[], walk=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false);
  629. while(n=walk.nextNode()) a.push(n);
  630. return a;
  631. }
  632.  
  633. function getPageContent(doc, cb){
  634. if(!doc)return i18n.error;
  635. if(processFunc){
  636. return processFunc(doc, cb);
  637. }
  638. [].forEach.call(doc.querySelectorAll("span,div,ul"),function(item){
  639. var thisStyle=doc.defaultView?doc.defaultView.getComputedStyle(item):item.style;
  640. if(thisStyle && (thisStyle.display=="none" || (item.nodeName=="SPAN" && thisStyle.fontSize=="0px"))){
  641. item.innerHTML="";
  642. }
  643. });
  644. var i,j,k,rStr="",pageData=(doc.body?doc.body:doc).cloneNode(true),delList=[];
  645. pageData.innerHTML=pageData.innerHTML.replace(/\<\!\-\-((.|[\n|\r|\r\n])*?)\-\-\>/g,"");
  646. [].forEach.call(pageData.querySelectorAll("font.jammer"),function(item){
  647. item.innerHTML="";
  648. });
  649. var selectors=GM_getValue("selectors");
  650. if(selectors){
  651. [].forEach.call(pageData.querySelectorAll(selectors),function(item){
  652. item.innerHTML="";
  653. });
  654. }
  655. [].forEach.call(pageData.querySelectorAll("script,style,link,img,noscript,iframe"),function(item){delList.push(item);});
  656. [].forEach.call(delList,function(item){item.innerHTML="";});
  657. var endEle = ele => {
  658. return /^(I|STRONG|B|FONT|P|DL|DD|H\d)$/.test(ele.nodeName) && ele.children.length == 0;
  659. };
  660. var largestContent,contents=pageData.querySelectorAll("span,div,article,p,td"),largestNum=0;
  661. for(i=0;i<contents.length;i++){
  662. let content=contents[i],hasText=false,allSingle=true,item,curNum=0;
  663. for(j=content.childNodes.length-1;j>=0;j--){
  664. item=content.childNodes[j];
  665. if(item.nodeType==3){
  666. if(/^\s*$/.test(item.data))
  667. item.innerHTML="";
  668. else hasText=true;
  669. }else if(/^(I|A|STRONG|B|FONT|P|DL|DD|H\d)$/.test(item.nodeName)){
  670. hasText=true;
  671. }else if(item.nodeType==1&&item.children.length==1&&/^(I|A|STRONG|B|FONT|P|DL|DD|H\d)$/.test(item.children[0].nodeName)){
  672. hasText=true;
  673. }
  674. }
  675. for(j=content.childNodes.length-1;j>=0;j--){
  676. item=content.childNodes[j];
  677. if(item.nodeType==1 && !/^(I|A|STRONG|B|FONT|BR)$/.test(item.nodeName) && /^[\s\-\_\?\>\|]*$/.test(item.innerHTML))
  678. item.innerHTML="";
  679. }
  680. if(content.childNodes.length>1){
  681. let indexItem=0;
  682. for(j=0;j<content.childNodes.length;j++){
  683. item=content.childNodes[j];
  684. if(item.nodeType==1){
  685. if(item.innerText && item.innerText.length<50 && indexReg.test(item.innerText))indexItem++;
  686. for(k=0;k<item.childNodes.length;k++){
  687. var childNode=item.childNodes[k];
  688. if(childNode.nodeType!=3 && !/^(I|A|STRONG|B|FONT|BR)$/.test(childNode.nodeName)){
  689. allSingle=false;
  690. break;
  691. }
  692. }
  693. if(!allSingle)break;
  694. }
  695. }
  696. if(indexItem>=5)continue;
  697. }else{
  698. allSingle=false;
  699. }
  700. if(!allSingle && !hasText){
  701. continue;
  702. }else {
  703. if(pageData==document && content.offsetWidth<=0 && content.offsetHeight<=0)
  704. continue;
  705. [].forEach.call(content.childNodes,function(item){
  706. if(item.nodeType==3)curNum+=item.data.trim().length;
  707. else if(endEle(item) || (item.nodeType == 1 && item.children.length == 1 && endEle(item.children[0]))) curNum += (firefox ? item.textContent.trim().length : item.innerText.trim().length);
  708. });
  709. }
  710. if(curNum>largestNum){
  711. largestNum=curNum;
  712. largestContent=content;
  713. }
  714. }
  715. if(!largestContent)return i18n.error+" : NO TEXT CONTENT";
  716. var childlist=pageData.querySelectorAll(largestContent.nodeName);//+(largestContent.className?"."+largestContent.className.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, '.'):""));
  717. function getRightStr(ele, noTextEnable){
  718. let childNodes=ele.childNodes,cStr="\r\n",hasText=false;
  719. [].forEach.call(ele.querySelectorAll("a[href]"), a => {
  720. a.parentNode && a.parentNode.removeChild(a);
  721. });
  722. for(let j=0;j<childNodes.length;j++){
  723. let childNode=childNodes[j];
  724. if(childNode.nodeType==3 && childNode.data && !/^[\s\-\_\?\>\|]*$/.test(childNode.data))hasText=true;
  725. if(childNode.innerHTML){
  726. childNode.innerHTML=childNode.innerHTML.replace(/\<\s*br\s*\>/gi,"\r\n").replace(/\n+/gi,"\n").replace(/\r+/gi,"\r");
  727. }
  728. if(childNode.textContent){
  729. cStr+=childNode.textContent.replace(/ +/g," ").replace(/([^\r]|^)\n([^\r]|$)/gi,"$1\r\n$2");
  730. }
  731. if(childNode.nodeType!=3 && !/^(I|A|STRONG|B|FONT)$/.test(childNode.nodeName))cStr+="\r\n";
  732. }
  733. if(hasText || noTextEnable || ele==largestContent)rStr+=cStr+"\r\n";
  734. }
  735. for(i=0;i<childlist.length;i++){
  736. var child=childlist[i];
  737. if(getDepth(child)==getDepth(largestContent)){
  738. if(largestContent.className != child.className)continue;
  739. if((largestContent.className && largestContent.className == child.className) || largestContent.parentNode == child.parentNode){
  740. getRightStr(child, true);
  741. }else {
  742. getRightStr(child, false);
  743. }
  744. }
  745. }
  746. return rStr.replace(/[\n\r]+/g,"\n\r");
  747. }
  748.  
  749. function getI18n(key, args){
  750. var resultStr=i18n[key];
  751. if(args && args.length>0){
  752. args.forEach(function(item){
  753. resultStr=resultStr.replace(/%s/,item);
  754. });
  755. }
  756. return resultStr;
  757. }
  758.  
  759. function getDepth(dom){
  760. var pa=dom,i=0;
  761. while(pa.parentNode){
  762. pa=pa.parentNode;
  763. i++;
  764. }
  765. return i;
  766. }
  767.  
  768. function fetch(forceSingle){
  769. forceSingle=forceSingle===true;
  770. processFunc=null;
  771. var aEles=document.body.querySelectorAll("a"),list=[];
  772. for(var i=0;i<aEles.length;i++){
  773. var aEle=aEles[i],has=false;
  774. if((!aEle.href || aEle.href.indexOf("javascript")!=-1) && aEle.dataset.href){
  775. aEle.href=aEle.dataset.href;
  776. }
  777. for(var j=0;j<list.length;j++){
  778. if(list[j].href==aEle.href){
  779. aEle=list[j];
  780. list.splice(j,1);
  781. list.push(aEle);
  782. has=true;
  783. break;
  784. }
  785. }
  786. if(!has && aEle.href && /^http/i.test(aEle.href) && ((aEle.innerText.trim()!="" && indexReg.test(aEle.innerText.trim())) || /chapter[\-_]?\d/.test(aEle.href))){
  787. list.push(aEle);
  788. }
  789. }
  790. if(list.length>2 && !forceSingle){
  791. indexDownload(list);
  792. }else{
  793. var blob = new Blob([i18n.info+"\r\n\r\n"+document.title+"\r\n\r\n"+getPageContent(document)], {type: "text/plain;charset=utf-8"});
  794. saveAs(blob, document.title+".txt");
  795. }
  796. }
  797.  
  798. function customDown(){
  799. processFunc=null;
  800. var customRules=GM_getValue("DACrules_"+document.domain);
  801. var urls=window.prompt(i18n.customInfo,customRules?customRules:"https://xxx.xxx/book-[20-99].html, https://xxx.xxx/book-[01-10].html");
  802. if(urls){
  803. urls=decodeURIComponent(urls.replace(/%/g,'%25'));
  804. GM_setValue("DACrules_"+document.domain, urls);
  805. var processEles=[];
  806. let urlsArr=urls.split("@@"),eles=[];
  807. if(/^http|^ftp/.test(urlsArr[0])){
  808. [].forEach.call(urlsArr[0].split(","),function(i){
  809. var curEle;
  810. var varNum=/\[\d+\-\d+\]/.exec(i);
  811. if(varNum){
  812. varNum=varNum[0].trim();
  813. }else{
  814. curEle=document.createElement("a");
  815. curEle.href=i;
  816. processEles.push(curEle);
  817. return;
  818. }
  819. var num1=/\[(\d+)/.exec(varNum)[1].trim();
  820. var num2=/(\d+)\]/.exec(varNum)[1].trim();
  821. var num1Int=parseInt(num1);
  822. var num2Int=parseInt(num2);
  823. var numLen=num1.length;
  824. var needAdd=num1.charAt(0)=="0";
  825. if(num1Int>=num2Int)return;
  826. for(var j=num1Int;j<=num2Int;j++){
  827. var urlIndex=j.toString();
  828. if(needAdd){
  829. while(urlIndex.length<numLen)urlIndex="0"+urlIndex;
  830. }
  831. var curUrl=i.replace(/\[\d+\-\d+\]/,urlIndex).trim();
  832. curEle=document.createElement("a");
  833. curEle.href=curUrl;
  834. curEle.innerText=processEles.length.toString();
  835. processEles.push(curEle);
  836. }
  837. });
  838. }else{
  839. let urlSel=urlsArr[0].split(">>");
  840. try{
  841. eles=document.querySelectorAll(urlSel[0]);
  842. eles=[].filter.call(eles, ele=>{
  843. return ele.nodeName=='BODY'||(!!ele.offsetParent&&getComputedStyle(ele).display!=='none');
  844. })
  845. }catch(e){}
  846. if(eles.length==0){
  847. eles=[];
  848. var eleTxts=urlsArr[0].split(/(?<=[^\\])[,,]/),exmpEles=[],excludeTxts={};
  849. [].forEach.call(document.querySelectorAll("a"),function(item){
  850. eleTxts.forEach(txt=>{
  851. var txtArr=txt.split("!");
  852. if(item.innerText.indexOf(txtArr[0])!=-1){
  853. exmpEles.push(item);
  854. excludeTxts[item]=txtArr.splice(1);
  855. }
  856. });
  857. })
  858. exmpEles.forEach(e=>{
  859. var cssSelStr="a",pa=e.parentNode,excludeTxt=excludeTxts[e];
  860. if(e.className)cssSelStr+="."+CSS.escape(e.className);
  861. while(pa && pa.nodeName!="BODY"){
  862. cssSelStr=pa.nodeName+">"+cssSelStr;
  863. pa=pa.parentNode;
  864. }
  865. [].forEach.call(document.querySelectorAll(cssSelStr),function(item){
  866. var isExclude=false;
  867. for(var t in excludeTxt){
  868. if(item.innerText.indexOf(excludeTxt[t])!=-1){
  869. isExclude=true;
  870. break;
  871. }
  872. }
  873. if(!isExclude && eles.indexOf(item)==-1){
  874. eles.push(item);
  875. }
  876. });
  877. });
  878. }
  879. function addItem(item) {
  880. let has=false;
  881. for(var j=0;j<processEles.length;j++){
  882. if(processEles[j].href==item.href){
  883. processEles.splice(j,1);
  884. processEles.push(item);
  885. has=true;
  886. break;
  887. }
  888. }
  889. if((!item.href || item.href.indexOf("javascript")!=-1) && item.dataset.href){
  890. item.href=item.dataset.href;
  891. }
  892. if(!has && item.href && /^http/i.test(item.href)){
  893. processEles.push(item.cloneNode(1));
  894. }
  895. }
  896. [].forEach.call(eles,function(item){
  897. if(urlSel[1]){
  898. item=Function("item",urlSel[1])(item);
  899. let items;
  900. if (Array.isArray(item)) {
  901. items = item;
  902. } else items = [item];
  903. items.forEach(item => {
  904. if(!item || !item.href)return;
  905. if(!item.nodeName || item.nodeName!="A"){
  906. let href=item.href;
  907. let innerText=item.innerText;
  908. item=document.createElement("a");
  909. item.href=href;
  910. item.innerText=innerText;
  911. }
  912. addItem(item);
  913. });
  914. } else {
  915. addItem(item);
  916. }
  917. });
  918. }
  919. if(urlsArr[1]){
  920. processEles.forEach(ele=>{
  921. ele.href=ele.href.replace(new RegExp(urlsArr[1]), urlsArr[2]);
  922. });
  923. }
  924. if(urlsArr[3]){
  925. processFunc=(data, cb)=>{
  926. let doc=data;
  927. if(urlsArr[3].indexOf("return ")==-1){
  928. if(urlsArr[3].indexOf("@")==0){
  929. let content="";
  930. [].forEach.call(data.querySelectorAll(urlsArr[3].slice(1)), ele=>{
  931. [].forEach.call(ele.childNodes, child=>{
  932. if(child.innerHTML){
  933. child.innerHTML=child.innerHTML.replace(/\<\s*br\s*\>/gi,"\r\n").replace(/\n+/gi,"\n").replace(/\r+/gi,"\r");
  934. }
  935. if(child.textContent){
  936. content+=(child.textContent.replace(/ +/g," ").replace(/([^\r]|^)\n([^\r]|$)/gi,"$1\r\n$2")+"\r\n");
  937. }
  938. });
  939. content+="\r\n";
  940. });
  941. return content;
  942. }else return eval(urlsArr[3]);
  943. }else{
  944. return Function("data", "doc", "cb",urlsArr[3])(data, doc, cb);
  945. }
  946. };
  947. }else{
  948. if(win.dacProcess){
  949. processFunc=win.dacProcess;
  950. }
  951. }
  952. indexDownload(processEles);
  953. }
  954. }
  955. const configPage = "https://hoothin.github.io/UserScripts/DownloadAllContent/";
  956. const copySvg = '<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" style="transition: all ease 0.5s;top: 5px;right: 5px;position: absolute;cursor: pointer;"><title>Copy</title><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg>';
  957. function searchRule(){
  958. GM_openInTab(configPage + "#@" + location.hostname, {active: true});
  959. }
  960. if (location.origin + location.pathname == configPage) {
  961. let exampleNode = document.getElementById("example");
  962. if (!exampleNode) return;
  963.  
  964. exampleNode = exampleNode.parentNode;
  965. let ruleList = exampleNode.nextElementSibling.nextElementSibling;
  966. let searchInput = document.createElement("input");
  967. let inputTimer;
  968. function searchByInput() {
  969. clearTimeout(inputTimer);
  970. inputTimer = setTimeout(() => {
  971. let curValue = searchInput.value;
  972. let matchRules = [];
  973. let dontMatchRules = [];
  974. if (curValue) {
  975. for (let i = 0; i < ruleList.children.length; i++) {
  976. let curRule = ruleList.children[i];
  977. let aHref = curRule.firstChild.href;
  978. if (aHref.indexOf(curValue) == -1) {
  979. dontMatchRules.push(curRule);
  980. } else {
  981. matchRules.push(curRule);
  982. }
  983. }
  984. } else {
  985. dontMatchRules = ruleList.children;
  986. }
  987. if (matchRules.length) {
  988. for (let i = 0; i < dontMatchRules.length; i++) {
  989. let curRule = dontMatchRules[i];
  990. curRule.style.display = "none";
  991. }
  992. for (let i = 0; i < matchRules.length; i++) {
  993. let curRule = matchRules[i];
  994. curRule.style.display = "";
  995. }
  996. } else {
  997. for (let i = 0; i < dontMatchRules.length; i++) {
  998. let curRule = dontMatchRules[i];
  999. curRule.style.display = "";
  1000. }
  1001. }
  1002. }, 500);
  1003. }
  1004. searchInput.style.margin = "10px";
  1005. searchInput.style.width = "100%";
  1006. searchInput.placeholder = i18n.searchRule;
  1007. searchInput.addEventListener("input", function(e) {
  1008. searchByInput();
  1009. });
  1010. if (location.hash) {
  1011. let hash = location.hash.slice(1);
  1012. if (hash.indexOf("@") == 0) {
  1013. setTimeout(() => {
  1014. exampleNode.scrollIntoView();
  1015. }, 500);
  1016. searchInput.value = hash.slice(1);
  1017. searchByInput();
  1018. }
  1019. }
  1020. [].forEach.call(ruleList.querySelectorAll("div.highlight"), highlight => {
  1021. highlight.style.position = "relative";
  1022. highlight.innerHTML = highlight.innerHTML + copySvg;
  1023. let svg = highlight.children[1];
  1024. svg.addEventListener("click", function(e) {
  1025. GM_setClipboard(highlight.children[0].innerText);
  1026. svg.style.opacity = 0;
  1027. setTimeout(() => {
  1028. svg.style.opacity = 1;
  1029. }, 1000);
  1030. });
  1031. });
  1032. exampleNode.parentNode.insertBefore(searchInput, ruleList);
  1033.  
  1034.  
  1035. let donateNode = document.querySelector("[alt='donate']");
  1036. if (!donateNode) return;
  1037. let insertPos = donateNode.parentNode.nextElementSibling;
  1038. let radioIndex = 0;
  1039. function createOption(_name, _value, _type) {
  1040. if (!_type) _type = "input";
  1041. let con = document.createElement("div");
  1042. let option = document.createElement("input");
  1043. let cap = document.createElement("b");
  1044. option.type = _type;
  1045. option.value = _value;
  1046. option.checked = _value;
  1047. cap.style.margin = "10px 10px 10px 0px";
  1048. if (_type == "radio") {
  1049. let label = document.createElement("label");
  1050. label.innerText = _name;
  1051. radioIndex++;
  1052. option.id = "radio" + radioIndex;
  1053. label.setAttribute("for", option.id);
  1054. cap.appendChild(label);
  1055. } else {
  1056. cap.innerText = _name;
  1057. }
  1058. con.style.margin = "10px 0";
  1059. con.appendChild(cap);
  1060. con.appendChild(option);
  1061. insertPos.parentNode.insertBefore(con, insertPos);
  1062. return option;
  1063. }
  1064. let delSelector = createOption(i18n.del, GM_getValue("selectors") || "");
  1065. delSelector.setAttribute("placeHolder", ".mask,.ksam");
  1066. let downThreadNum = createOption(i18n.downThreadNum, GM_getValue("downThreadNum") || "20");
  1067. let customTitle = createOption(i18n.customTitle, GM_getValue("customTitle") || "");
  1068. customTitle.setAttribute("placeHolder", "title");
  1069. let contentSortUrlValue = GM_getValue("contentSortUrl") || false;
  1070. let contentSortValue = GM_getValue("contentSort") || false;
  1071. let reSortDefault = createOption(i18n.reSortDefault, !contentSortUrlValue && !contentSortValue, "radio");
  1072. let reSortUrl = createOption(i18n.reSortUrl, contentSortUrlValue || false, "radio");
  1073. let contentSort = createOption(i18n.reSort, contentSortValue || false, "radio");
  1074. reSortDefault.name = "sort";
  1075. reSortUrl.name = "sort";
  1076. contentSort.name = "sort";
  1077. let reverse = createOption(i18n.reverse, GM_getValue("reverse") || false, "checkbox");
  1078. let saveBtn = document.createElement("button");
  1079. saveBtn.innerText = i18n.saveBtn;
  1080. insertPos.parentNode.insertBefore(saveBtn, insertPos);
  1081. saveBtn.onclick = e => {
  1082. GM_setValue("selectors", delSelector.value || "");
  1083. GM_setValue("downThreadNum", downThreadNum.value || 20);
  1084. GM_setValue("customTitle", customTitle.value || "");
  1085. if (reSortUrl.checked) {
  1086. GM_setValue("contentSortUrl", true);
  1087. GM_setValue("contentSort", false);
  1088. } else if (contentSort.checked) {
  1089. GM_setValue("contentSortUrl", false);
  1090. GM_setValue("contentSort", true);
  1091. } else {
  1092. GM_setValue("contentSortUrl", false);
  1093. GM_setValue("contentSort", false);
  1094. }
  1095. GM_setValue("reverse", reverse.checked);
  1096. alert(i18n.saveOk);
  1097. };
  1098. return;
  1099. }
  1100.  
  1101. function setDel(){
  1102. GM_openInTab(configPage + "#操作說明", {active: true});
  1103. return;
  1104. /*var selValue=GM_getValue("selectors");
  1105. var selectors=prompt(i18n.del,selValue?selValue:"");
  1106. GM_setValue("selectors",selectors);
  1107. selValue=GM_getValue("downThreadNum");
  1108. var downThreadNum=prompt(i18n.downThreadNum,selValue?selValue:"20");
  1109. GM_setValue("downThreadNum",downThreadNum);
  1110. var sortByUrl=window.confirm(i18n.reSortUrl);
  1111. GM_setValue("contentSortUrl",sortByUrl);
  1112. if(!sortByUrl)GM_setValue("contentSort",window.confirm(i18n.reSort));*/
  1113. }
  1114.  
  1115. document.addEventListener("keydown", function(e) {
  1116. if(e.keyCode == 120 && e.ctrlKey) {
  1117. fetch(e.shiftKey);
  1118. }
  1119. });
  1120. GM_registerMenuCommand(i18n.fetch, fetch);
  1121. GM_registerMenuCommand(i18n.custom, customDown);
  1122. GM_registerMenuCommand(i18n.setting, setDel);
  1123. GM_registerMenuCommand(i18n.searchRule, searchRule);
  1124. })();