├── README.md ├── nong-drive.js └── nong.js /README.md: -------------------------------------------------------------------------------- 1 | # nong 2 | 3 | 此项目不再维护, 祝愿大家身体健康. 4 | 5 | >在支持的网站获取番号,然后显示搜索到的磁链接 6 | 7 | >现在拥有的功能: 8 | * 复制磁链接 9 | * 转到支持的网盘开始离线下载 10 | -------------------------------------------------------------------------------- /nong-drive.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 挊-随时开车 3 | // @namespace 撸 4 | // @description 自动获取磁链接并自动离线下载 5 | 6 | 7 | // @include http*://* 8 | 9 | // @version 1.39 10 | // @run-at document-end 11 | // @grant GM_xmlhttpRequest 12 | // @grant GM_setClipboard 13 | // @grant GM_setValue 14 | // @grant GM_getValue 15 | // @grant GM_addStyle 16 | // @grant unsafeWindow 17 | // @grant GM_registerMenuCommand 18 | // @noframes 19 | // ==/UserScript== 20 | 21 | let i_am_old_driver = { 22 | start: function () { 23 | this.add_css(); 24 | this.add_small_icon(); 25 | }, 26 | add_css: function () { 27 | if (!unsafeWindow.add_css_flag) { 28 | unsafeWindow.add_css_flag = true; 29 | var css = '\ 30 | #nong-drive-anytime-icon{\ 31 | position:fixed;\ 32 | z-index:6969;\ 33 | color: white;\ 34 | border-radius: 32px;\ 35 | width: 32px;\ 36 | height: 32px;\ 37 | left: 10px;\ 38 | bottom: 15px;\ 39 | opacity:0.1;\ 40 | text-align: center;\ 41 | line-height: 32px;\ 42 | -webkit-transition: opacity 0.6s ease-in-out;\ 43 | -moz-transition: opacity 1s ease-in-out;\ 44 | -o-transition: opacity 1s ease-in-out;\ 45 | transition: opacity 1s ease-in-out;\ 46 | background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0A\ 47 | AAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0Q\ 48 | A/wD/AP+gvaeTAAAAB3RJTUUH3gwKEBo6JKpagwAAA/lJREFUWMPtlk1oXFUUgL/z3ps3mUlmJmli0iZ26E9KSAuWq\ 49 | tSdQkQoKKIUXfi3KlhUkJKdaEREurHFjTttcaHUgiD+oJCdtIq01kpBS5Mmtvkh6cwkmc5fkjdzj4uXKc1kppOOEQQ\ 50 | 9q3vfO/ee755z7jkX/usi9RQee+7QujYa/uyjjQWoYrgZiAEOoEAGSK+MGwapClBhfAfwIjAAdAMuYIAkcAE4CZwHi\ 51 | o1ArAE48NJhjDGYUskVkUPAEaAXVVTVX6GACCLCCsgp4F3gxt1COJXGAWzbdkXkbVMqHUE1hGURjLYRbt9MsLUdL58\ 52 | ln5xhaSGJKXodiLwGbAdeBqYaDkEZAHgFeF+NCVnBED37H+We3Q/gtsQQxwFj8Ao50tdHmDjzHfnENPje+AR4Fcit1\ 53 | wt2FeM7gQ9R7XLDLfQdeIau+x8mEI4gloWIIJaFHQzR0nkv0a07yEz/iZdNg0gfcBG4DDB26UJdAKvKtxeAXiyL+P5\ 54 | H2NJ/H65lQM1qLVVUDS2b42wfeBon3AKqIeAwEFlvCCoBmoEBVGmKxOjq3+uflhIBKVa9MmoM0fguIt3b/CSFfUC8U\ 55 | YAY0K2qhNs7CUZi5U1xxNSEsJ0AsfguxLIAokBPowAO4CIQim1CbGf1z1oQIjS1diC2Xd6j4RAoYFDw8jnUmDULqkI\ 56 | oeIUc+PoGWGwUIAMkESGXmqVYyJWv1x0hjCmSmbyKKZUA8sBsowBp4IKIUFiYY35iDKnRLm5BiFBI3SA9cbVcGceBa\ 57 | 38nBCeBpCl6jJ8dJjM7WU6uNRKwgMU013/4mqV0CkQM8DGQaBQA/MZyChFyiRl+//ZzUmOXMaXirSIkYqGqZJMzjH5\ 58 | /mrmRS34o4GzCcU/vLmR5Z+rKugBqleJO4ATwuKrihpuJbonTFt9JU+smioU8C5PjLEyOs5ieB2Apn2NPYvqrN5bSn\ 59 | 4rIN8bPBXp+OtcQAPh3+T3gWVRDquqf3rJBjZ9wfkdUA2f2Jafmnl/KPNlRyC+q6gf43bFQD8K+fTL623l69z5Ynma\ 60 | AYeAiIm0iEgVs/MJUFJGMiPwBHE2IPXRCs9loMPiEIiHjLT8EBIAfgeLg1h6OT07X90ANT4BfWOIrXong3/NZ4BpoY\ 61 | k/JY2hxLmzgTVQHvVzW9TKZZVSP1fPEHd+EVUCqytFCim3GAwgBb6E6WMznXO/mzWWtA1H3UbpemT/4VHnoQ8BgMZe\ 62 | tC2HdnZna0vbFl+VhYcXYMae5ZTkQjbliWYPAEBCuXLdhALUhmpcD0agrlnUQ1TVdckMBakAcd8LhkUAk+nrq119GK\ 63 | /U3LAcq5bacCAM9sb7+0eS5n9XLZlblwD8GUAFRzUP/y79D/gKteao6M/AMZwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjA\ 64 | xNi0wOS0xN1QxNToyMToyNiswODowMH9bMZYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTQtMTItMTBUMTY6MjY6NTgrM\ 65 | Dg6MDAX0x1GAAAATXRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA3LjAuMS02IFExNiB4ODZfNjQgMjAxNi0wOS0xNyB\ 66 | odHRwOi8vd3d3LmltYWdlbWFnaWNrLm9yZ93ZpU4AAAAYdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AA\ 67 | AAYdEVYdFRodW1iOjpJbWFnZTo6SGVpZ2h0ADEyOEN8QYAAAAAXdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgAMTI40I0\ 68 | R3QAAABl0RVh0VGh1bWI6Ok1pbWV0eXBlAGltYWdlL3BuZz+yVk4AAAAXdEVYdFRodW1iOjpNVGltZQAxNDE4MjAwM\ 69 | DE4ibQBZAAAABJ0RVh0VGh1bWI6OlNpemUAMi4zM0tCSV84/gAAAF90RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWU\ 70 | vd3d3cm9vdC9zaXRlL3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9zcmMvMTE4MjEvMTE4MjE5M\ 71 | S5wbmd8fDQnAAAAAElFTkSuQmCC");\ 72 | }\ 73 | #nong-drive-anytime-dialog{\ 74 | position:fixed;\ 75 | left:8%;\ 76 | top:10%;\ 77 | z-index:69699;\ 78 | border-radius: 8px 8px;\ 79 | padding-top: 10px;\ 80 | padding-left:10px;\ 81 | padding-right:10px;\ 82 | background-color: rgba(237, 237, 237, 0.8);\ 83 | }\ 84 | #nong-drive-anytime-dialog>span{\ 85 | margin-left: 40px;\ 86 | }\ 87 | #nong-drive-anytime-dialog #nong-move{\ 88 | width: 16px;\ 89 | height: 16px;\ 90 | display:none;\ 91 | background-image: url("data:image/png;ba\ 92 | se64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQ\ 93 | AAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfeChoLIiwIy72HAAAA3ElEQVQ\ 94 | oz3XRsUrDYBQF4C9NVnFRB8fiLFhEcJAOHRJw6FApdLBv4EP4An0QQeyatZMdsjiok+DiA7jEJcShaZs0eob/Hg6H+99\ 95 | 7bqiJqVMv/kViaSmuS2GN91179upM7rNtCJyb2/PtyYn33eZBVScmTaVTNR+15hnprw2JoaySC0XFMkMJkVt3Hly4ROE\ 96 | KgRCFL/cOI5Qo/3g3iM10Kz42rljXTEyEVK7nY2ftnrnFysBis+YWj6tP6kHd+HGslBt4W89Qj/rAVMe+gWwbdRNx+1h\ 97 | Rw5A6QlqXfgFuOzSValRoagAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNi0wOS0xN1QxNToyMToxNyswODowMFejPcEAAAA\ 98 | ldEVYdGRhdGU6bW9kaWZ5ADIwMTQtMTAtMjZUMTE6MzQ6NDQrMDg6MDDQbkqYAAAATXRFWHRzb2Z0d2FyZQBJbWFnZU1\ 99 | hZ2ljayA3LjAuMS02IFExNiB4ODZfNjQgMjAxNi0wOS0xNyBodHRwOi8vd3d3LmltYWdlbWFnaWNrLm9yZ93ZpU4AAAA\ 100 | YdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AAAAYdEVYdFRodW1iOjpJbWFnZTo6SGVpZ2h0ADUxMo+NU4E\ 101 | AAAAXdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgANTEyHHwD3AAAABl0RVh0VGh1bWI6Ok1pbWV0eXBlAGltYWdlL3BuZz+\ 102 | yVk4AAAAXdEVYdFRodW1iOjpNVGltZQAxNDE0Mjk0NDg0ExvBiAAAABJ0RVh0VGh1bWI6OlNpemUAMTUuMktCe0oJtgA\ 103 | AAF90RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC9zaXRlL3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5\ 104 | lYXN5aWNvbi5jbi9zcmMvMTE3NzQvMTE3NzQ3Ni5wbmf8M3m2AAAAAElFTkSuQmCC"\);\ 105 | display: none;\ 106 | float: right;opacity: 0.4;\ 107 | cursor:pointer;\ 108 | }\ 109 | #nong-drive-anytime-dialog>button{\ 110 | margin-left: 12px;\ 111 | }\ 112 | #nong-drive-anytime-dialog > table{\ 113 | \ 114 | }\ 115 | #nong-table-wrapper {\ 116 | overflow-x: hidden;\ 117 | overflow-y: auto;\ 118 | position: relative;\ 119 | max-height: 30em;\ 120 | }\ 121 | #nong-drive-anytime-icon:hover{\ 122 | opacity:1;\ 123 | }\ 124 | '; 125 | GM_addStyle(css); 126 | } 127 | }, 128 | selection: "", 129 | add_small_icon: function () { 130 | let icon = document.createElement("div"); 131 | icon.setAttribute("id", "nong-drive-anytime-icon"); 132 | icon.addEventListener("mouseover", (e) => { 133 | let text = unsafeWindow.getSelection().toString(); 134 | console.info("选中的文本:", text); 135 | this.selection = text; 136 | }); 137 | icon.addEventListener("click", (e) => { 138 | if (this.selection === "") { 139 | this.selection = unsafeWindow.getSelection().toString(); 140 | } 141 | this.display_dialog(); 142 | }); 143 | document.body.appendChild(icon); 144 | }, 145 | display_dialog: function () { 146 | let dialog = document.createElement("div"); 147 | dialog.setAttribute("id", "nong-drive-anytime-dialog"); 148 | dialog.addEventListener("click", (event) => { 149 | event.stopPropagation(); 150 | }); 151 | let span = document.createElement("span"); 152 | span.textContent = "番号:"; 153 | dialog.appendChild(span); 154 | let vid_input = document.createElement("input"); 155 | vid_input.value = this.selection; 156 | vid_input.addEventListener("keypress", (e) => { 157 | if (e.key === "Enter") { 158 | e.target.nextElementSibling.click(); 159 | } 160 | }); 161 | dialog.appendChild(vid_input); 162 | 163 | let btn = document.createElement("button"); 164 | btn.textContent = "确定"; 165 | btn.addEventListener("click", (e) => { 166 | this.selection = vid_input.value; 167 | display_table(this.selection, null); 168 | }); 169 | dialog.appendChild(btn); 170 | 171 | let move = document.createElement("div"); 172 | 173 | move.setAttribute("id", "nong-move"); 174 | move.setAttribute("draggable","true"); 175 | { 176 | let ismoving = false; 177 | // move.addEventListener("mousedown",(e)=>{ 178 | // ismoving = true; 179 | // console.log("down"); 180 | // }); 181 | move.addEventListener("dragstart",(e)=>{ 182 | console.log("drag",e); 183 | dialog.style.left = (dialog.offsetLeft+e.movementX)+"px"; 184 | dialog.style.top = (dialog.offsetTop+e.movementY)+"px"; 185 | }); 186 | // move.addEventListener("mouseup",(e)=>{ 187 | // ismoving =false; 188 | // console.log("up") 189 | // }); 190 | 191 | } 192 | 193 | 194 | dialog.appendChild(move); 195 | document.body.appendChild(dialog); 196 | 197 | display_table(this.selection, function (tab) { 198 | 199 | let outer_table = document.createElement("table"); 200 | outer_table.appendChild(document.createElement("tr")); 201 | outer_table.lastChild.appendChild(document.createElement("th")); 202 | outer_table.appendChild(document.createElement("tr")); 203 | outer_table.lastChild.appendChild(document.createElement("td")); 204 | let wrapper = document.createElement("div"); 205 | wrapper.id = "nong-table-wrapper"; 206 | wrapper.appendChild(tab); 207 | outer_table.querySelector("td").appendChild(wrapper); 208 | document.querySelector("#nong-drive-anytime-dialog").appendChild(outer_table); 209 | 210 | }); 211 | }, 212 | }; 213 | let main = { 214 | baidu: { 215 | type: 1, 216 | re: /pan\.baidu\.com\/disk\/home/, 217 | fill_form: function (magnet) { 218 | document.querySelector(".g-button[data-button-id=b13]").click(); 219 | setTimeout(function () { 220 | document.querySelector("#_disk_id_2").click(); 221 | setTimeout(function () { 222 | document.querySelector("#share-offline-link").value = magnet; 223 | document.querySelector(".g-button[data-button-id=b65]").click(); 224 | }, 500); 225 | }, 1500); 226 | } 227 | }, 228 | 115: { 229 | type: 1, 230 | re: /115\.com\/\?tab\=offline\&mode\=wangpan/, 231 | fill_form: function (link) { 232 | let rsc = setInterval(function () { 233 | if (document.readyState == "complete") { 234 | clearInterval(rsc); 235 | setTimeout(function () { 236 | Core["OFFL5Plug"].OpenLink(); 237 | setTimeout(function () { 238 | $("#js_offline_new_add").val(link); 239 | }, 300); 240 | }, 1000); 241 | } 242 | }, 400); 243 | } 244 | }, 245 | furk: { 246 | type: 1, 247 | re: /www\.furk\.net\/users\/files\/add/, 248 | fill_form: function (link) { 249 | setTimeout(function () { 250 | $("#url").val(link.replace("magnet:?xt=urn:btih:", "")); 251 | }, 1500); 252 | } 253 | } 254 | }; 255 | 256 | let offline_sites = { 257 | baidu: { 258 | url: "http://pan.baidu.com/disk/home", 259 | name: "百度云", 260 | enable: true 261 | }, 262 | 115: { 263 | name: "115离线", 264 | url: "http://115.com/?tab=offline&mode=wangpan", 265 | enable: true, 266 | }, 267 | letv: { 268 | name: "乐视云", 269 | url: "http://cloud.letv.com/webdisk/home/index", 270 | enable: false 271 | }, 272 | 360: { 273 | name: "360云", 274 | url: "http://yunpan.360.cn/my/", 275 | enable: false 276 | }, 277 | uc: { 278 | name: "UC离线", 279 | url: "http://disk.yun.uc.cn/", 280 | enable: false 281 | }, 282 | furk: { 283 | name: "Furk", 284 | url: "https://www.furk.net/users/files/add", 285 | enable: true 286 | }, 287 | }; 288 | let common = { 289 | add_style: function () { 290 | GM_addStyle([ 291 | "#nong-table{border-collapse: initial !important;background-color: white !important;text-align: center !important;margin:10px auto;color:#666 !important;font-size:13px;text-align:center !important;border: 1px solid #cfcfcf !important;border-radius: 10px !important;}", 292 | "#nong-table a {margin-right: 5px !important;color:blue}", 293 | "#nong-table a:hover {color:#d20f00 !important;}", 294 | "#nong-table th,#nong-table td{text-align: inherit !important;height:30px;padding:0 1em 0 !important;}", 295 | ".nong-row{text-align: inherit !important;height:30px;padding:0 1em 0 !important;border: 1px solid #EFEFEF !important;}", 296 | ".nong-row:hover{background-color: #dae8ff !important;}", 297 | ".nong-offline-download{color: rgb(0, 180, 30) !important;}", 298 | ".nong-offline-download:hover{color:red !important;}", 299 | ].join("")); 300 | }, 301 | handle_copy_event: function (event) { 302 | event.target.innerHTML = "成功"; 303 | GM_setClipboard(event.target.href); 304 | setTimeout(function () { 305 | event.target.innerHTML = "复制"; 306 | }, 1000); 307 | event.preventDefault(); //阻止跳转 308 | }, 309 | handle_dl_event: function (event) { 310 | let mag = event.target.parentElement.parentElement.parentElement.getAttribute("mag"); 311 | GM_setValue("magnet", mag); 312 | }, 313 | handle_close_event: function (event) { 314 | let dialog = document.querySelector("#nong-drive-anytime-dialog"); 315 | if (dialog) { 316 | dialog.parentElement.removeChild(dialog); 317 | } 318 | this.removeEventListener("click", common.handle_close_event); 319 | }, 320 | 321 | reg_event: function () { 322 | 323 | let selector_event_map = [{ 324 | selector: "#nong-drive-anytime-dialog .nong-copy", 325 | type: "click", 326 | fn: this.handle_copy_event 327 | }, { 328 | selector: "#nong-drive-anytime-dialog .nong-offline-download", 329 | type: "click", 330 | fn: this.handle_dl_event 331 | }]; 332 | 333 | selector_event_map.push({ selector: "body", type: "click", fn: this.handle_close_event }); 334 | for (let obj of selector_event_map) { 335 | for (let elem of document.querySelectorAll(obj.selector)) { 336 | //console.log(elem, obj.type, obj.fn); 337 | elem.addEventListener(obj.type, obj.fn); 338 | } 339 | } 340 | }, 341 | parsetext: function (text) { 342 | let doc = null; 343 | try { 344 | doc = document.implementation.createHTMLDocument(""); 345 | doc.documentElement.innerHTML = text; 346 | return doc; 347 | } catch (e) { 348 | alert("parse error"); 349 | } 350 | }, 351 | }; 352 | 353 | 354 | let magnet_table = { 355 | template: { 356 | create_head: function (src) { 357 | let a = document.createElement("tr"); 358 | a.className = "nong-row"; 359 | a.id = "nong-head"; 360 | let head_str = [ 361 | "大小", 362 | "操作", 363 | "离线下载" 364 | ]; 365 | let th_list = [document.createElement("th"), document.createElement("th"), document.createElement("th"), document.createElement("th")]; 366 | 367 | let select_box = document.createElement("select"); 368 | console.log(this); 369 | let option_str = my_search.search_name_string; 370 | //console.log("get", GM_getValue("search_index")); 371 | let index = GM_getValue("search_index", 0); 372 | let op_value = 0; 373 | for (let str of option_str) { 374 | let op = document.createElement("option"); 375 | op.value = op_value; 376 | op.textContent = str; 377 | if (index == op_value) { 378 | op.setAttribute("selected", "selected"); 379 | } 380 | op_value++; 381 | select_box.appendChild(op); 382 | } 383 | select_box.addEventListener("change", function (e) { 384 | GM_setValue("search_index", this.value); 385 | display_table(i_am_old_driver.selection, null); 386 | }); 387 | th_list[0].appendChild(select_box); 388 | 389 | th_list[1].appendChild(document.createElement("a")); 390 | th_list[1].lastChild.setAttribute("href", src); 391 | th_list[1].lastChild.setAttribute("target", "_blank"); 392 | th_list[1].lastChild.textContent = head_str[0]; 393 | 394 | th_list[2].appendChild(document.createElement("a")); 395 | th_list[2].lastChild.textContent = head_str[1]; 396 | 397 | th_list[3].appendChild(document.createElement("a")); 398 | th_list[3].lastChild.textContent = head_str[2]; 399 | 400 | for (let th of th_list) { 401 | a.appendChild(th); 402 | } 403 | return a; 404 | }, 405 | create_row: function (data) { 406 | let tr = document.createElement("tr"); 407 | tr.className = "nong-row"; 408 | tr.setAttribute("mag", data.mag); 409 | let td = document.createElement("td"); 410 | for (let elem of [this.create_info(data.title, data.mag), this.create_size(data.size, data.src), this.create_operation(data.mag), this.create_offline()]) { 411 | let c = td.cloneNode(true); 412 | c.appendChild(elem); 413 | tr.appendChild(c); 414 | } 415 | return tr; 416 | }, 417 | create_row_for_sukebei: function (data) { 418 | let tr = document.createElement("tr"); 419 | tr.className = "nong-row"; 420 | tr.setAttribute("mag", data.mag); 421 | let td = document.createElement("td"); 422 | let append_elems = [ 423 | this.create_info(data.title, data.src), 424 | this.create_size(data.size, data.src), 425 | ((torrent_url = data.torrent_url) => { 426 | let operate = this.create_operation(torrent_url); 427 | operate.firstChild.textContent = "种子"; 428 | operate.firstChild.setAttribute("class", "nong-copy-sukebei"); 429 | operate.firstChild.setAttribute("target", "_blank"); 430 | return operate; 431 | })(), 432 | (() => { 433 | let div = document.createElement("div"); 434 | div.textContent = "暂不支持离线下载"; 435 | return div; 436 | })() 437 | ]; 438 | for (let elem of append_elems) { 439 | let c = td.cloneNode(true); 440 | c.appendChild(elem); 441 | tr.appendChild(c); 442 | } 443 | return tr; 444 | }, 445 | create_info: function (title, mag) { 446 | let a = this.info.cloneNode(true); 447 | a.firstChild.textContent = title.length < max_title_length ? title : title.substr(0, max_title_length) + "..."; 448 | a.firstChild.href = mag; 449 | a.title = title; 450 | return a; 451 | }, 452 | create_size: function (size, src) { 453 | let a = this.size.cloneNode(true); 454 | a.textContent = size; 455 | a.href = src; 456 | return a; 457 | }, 458 | create_operation: function (mag) { 459 | let a = this.operation.cloneNode(true); 460 | a.firstChild.href = mag; 461 | return a; 462 | }, 463 | create_offline: function () { 464 | let a = this.offline.cloneNode(true); 465 | a.className = "nong-offline"; 466 | return a; 467 | }, 468 | 469 | info: (function () { 470 | let a = document.createElement("div"); 471 | let b = document.createElement("a"); 472 | b.textContent = "name"; 473 | b.href = "src"; 474 | b.target = "_blank"; 475 | a.appendChild(b); 476 | return a; 477 | })(), 478 | size: function () { 479 | let a = document.createElement("a"); 480 | a.textContent = "size"; 481 | return a; 482 | }(), 483 | operation: (function () { 484 | let a = document.createElement("div"); 485 | let copy = document.createElement("a"); 486 | copy.className = "nong-copy"; 487 | copy.textContent = "复制"; 488 | a.appendChild(copy); 489 | return a; 490 | })(), 491 | offline: (function () { 492 | let a = document.createElement("div"); 493 | let b = document.createElement("a"); 494 | b.className = "nong-offline-download"; 495 | b.target = "_blank"; 496 | for (let k in offline_sites) { 497 | if (offline_sites[k].enable) { 498 | let c = b.cloneNode(true); 499 | c.href = offline_sites[k].url; 500 | c.textContent = offline_sites[k].name; 501 | a.appendChild(c); 502 | } 503 | } 504 | return a; 505 | })(), 506 | }, 507 | generate_head: function () { 508 | let tab = document.createElement("table"); 509 | tab.id = "nong-table"; 510 | tab.appendChild(this.template.create_head("https://greasyfork.org/zh-CN/scripts/8392-%E6%8C%8A")); 511 | return tab; 512 | }, 513 | generate: function (src, data) { 514 | let tab = document.querySelector("#nong-drive-anytime-dialog #nong-table"); 515 | tab.querySelector("#nong-head a").href = src; 516 | if (src.match("nyaa.si")) { 517 | data.forEach((d) => { 518 | tab.appendChild(this.template.create_row_for_sukebei(d)); 519 | }); 520 | 521 | } else { 522 | data.forEach((d) => { 523 | tab.appendChild(this.template.create_row(d)); 524 | }); 525 | 526 | } 527 | return tab; 528 | }, 529 | 530 | }; 531 | let my_search = { 532 | 533 | search_name_string: ["btso", "btdb", "nyaa.si", "btkitty","torrentkitty","btlibrary"], 534 | current: function (kw, cb) { 535 | let search = my_search[GM_getValue("search_index", 0)]; 536 | try { 537 | return search(kw, cb); 538 | } 539 | catch (e) { 540 | this.search_error(); 541 | } 542 | }, 543 | search_error: function (r) { 544 | alert("搜索出现错误,请检查网络"); 545 | }, 546 | 0: function (kw, cb) { 547 | GM_xmlhttpRequest({ 548 | method: "GET", 549 | url: "https://btso.pw/search/" + kw, 550 | onload: function (result) { 551 | let doc = common.parsetext(result.responseText); 552 | let data = []; 553 | let t = doc.getElementsByClassName("data-list")[0]; 554 | if (t) { 555 | for (let elem of t.getElementsByTagName("a")) { 556 | if (!elem.className.match("btn")) { 557 | data.push({ 558 | "title": elem.title, 559 | "mag": "magnet:?xt=urn:btih:" + elem.outerHTML.replace(/.*hash\//, "").replace(/" .*\n.*\n.*\n.*/, ""), 560 | "size": elem.nextElementSibling.textContent, 561 | "src": elem.href, 562 | }); 563 | } 564 | } 565 | } 566 | else { 567 | data.push({ 568 | "title": "没有找到磁链接", 569 | "mag": "", 570 | "size": "0", 571 | "src": result.finalUrl, 572 | }); 573 | } 574 | cb(result.finalUrl, data); 575 | }, 576 | onerror: function (e) { 577 | console.error(e); 578 | throw "search error"; 579 | } 580 | }); 581 | }, 582 | 1: function (kw, cb) { 583 | GM_xmlhttpRequest({ 584 | method: "GET", 585 | url: "http://btdb.to/q/" + kw + "/", 586 | onload: function (result) { 587 | let doc = common.parsetext(result.responseText); 588 | let data = []; 589 | let t = doc.getElementsByClassName("item-title"); 590 | if (t) { 591 | for (let elem of t) { 592 | data.push({ 593 | "title": elem.firstChild.title, 594 | "mag": elem.nextElementSibling.firstElementChild.href, 595 | "size": elem.nextElementSibling.children[1].textContent, 596 | "src": "https://btdb.in" + elem.firstChild.getAttribute("href"), 597 | }); 598 | } 599 | } 600 | else { 601 | data.push({ 602 | "title": "没有找到磁链接", 603 | "mag": "", 604 | "size": "0", 605 | "src": result.finalUrl, 606 | }); 607 | } 608 | 609 | cb(result.finalUrl, data); 610 | }, 611 | onerror: function (e) { 612 | console.error(e); 613 | throw "search error"; 614 | } 615 | }); 616 | }, 617 | 2: function (kw, cb) { 618 | GM_xmlhttpRequest({ 619 | method: "GET", 620 | url: "https://sukebei.nyaa.si/?f=0&c=0_0&q=" + kw, 621 | onload: function (result) { 622 | let doc = common.parsetext(result.responseText); 623 | let data = []; 624 | let t = doc.querySelectorAll("tr.default"); 625 | if (t.length!==0) { 626 | for (let elem of t) { 627 | data.push({ 628 | "title": elem.querySelector("td:nth-child(2)>a:nth-child(1)").title, 629 | "mag": "", 630 | "torrent_url": "https://nyaa.si" + elem.querySelector("td:nth-child(3)>a:nth-child(1)").href, 631 | "size": elem.querySelector("td:nth-child(4)").textContent, 632 | "src": "https://nyaa.si" + elem.querySelector("td:nth-child(2)>a:nth-child(1)").href, 633 | }); 634 | } 635 | } 636 | else { 637 | data.push({ 638 | "title": "没有找到磁链接", 639 | "mag": "", 640 | "torrent_url": "", 641 | "size": "0", 642 | "src": result.finalUrl, 643 | }); 644 | } 645 | 646 | cb(result.finalUrl, data); 647 | }, 648 | onerror: function (e) { 649 | console.error(e); 650 | throw "search error"; 651 | } 652 | }); 653 | }, 654 | 3: function (kw, cb) { 655 | GM_xmlhttpRequest({ 656 | method: "POST", 657 | url: "http://btkitty.pet/", 658 | data: "keyword=" + kw+"&hidden=true", 659 | headers: { 660 | "Content-Type": "application/x-www-form-urlencoded" 661 | }, 662 | onload: function (result) { 663 | let doc = common.parsetext(result.responseText); 664 | let data = []; 665 | let t = doc.getElementsByClassName("list-con"); 666 | if (t) { 667 | for (let elem of t) { 668 | data.push({ 669 | "title": elem.querySelector("dt a").textContent, 670 | "mag": elem.querySelector("dd a").href, 671 | "size": elem.querySelector(".option span:nth-child(3) b").textContent, 672 | "src": elem.querySelector("dt a").href, 673 | }); 674 | } 675 | } 676 | else { 677 | data.push({ 678 | "title": "没有找到磁链接", 679 | "mag": "", 680 | "size": "0", 681 | "src": result.finalUrl, 682 | }); 683 | } 684 | cb(result.finalUrl, data); 685 | }, 686 | onerror: function (e) { 687 | console.error(e); 688 | throw "search error"; 689 | } 690 | }); 691 | }, 692 | 4: function (kw, cb) { 693 | GM_xmlhttpRequest({ 694 | method: "GET", 695 | url: "https://www.torrentkitty.tv/search/"+kw, 696 | onload: function (result) { 697 | let doc = common.parsetext(result.responseText); 698 | let data = []; 699 | let t = doc.querySelectorAll("#archiveResult tr"); 700 | if (t) { 701 | t = Array.slice(t,1,t.length) 702 | for (let elem of t) { 703 | data.push({ 704 | "title": elem.querySelector(".name").textContent, 705 | "mag": elem.querySelector(".action>a:nth-child(2)").href, 706 | "size": elem.querySelector(".size").textContent, 707 | "src": elem.querySelector(".action>a:nth-child(1)").href, 708 | }); 709 | } 710 | } 711 | else { 712 | data.push({ 713 | "title": "没有找到磁链接", 714 | "mag": "", 715 | "size": "0", 716 | "src": result.finalUrl, 717 | }); 718 | } 719 | cb(result.finalUrl, data); 720 | }, 721 | onerror: function (e) { 722 | console.error(e); 723 | throw "search error"; 724 | } 725 | }); 726 | }, 727 | 5: function (kw, cb) { 728 | GM_xmlhttpRequest({ 729 | method: "POST", 730 | url: "http://btlibrary.pw", 731 | data: "keyword=" + kw, 732 | headers: { 733 | "Content-Type": "application/x-www-form-urlencoded" 734 | }, 735 | onload: function (result) { 736 | let doc = common.parsetext(result.responseText); 737 | let data = []; 738 | let t = doc.querySelectorAll(".item"); 739 | if (t) { 740 | for (let elem of t) { 741 | data.push({ 742 | "title": elem.querySelector(".item-title>a").textContent, 743 | "mag": elem.querySelector(".item-detail>span:nth-child(1)>a").href, 744 | "size": elem.querySelector(".item-detail>span:nth-child(3)>b").textContent, 745 | "src": elem.querySelector(".item-title>a").href, 746 | }); 747 | } 748 | } 749 | else { 750 | data.push({ 751 | "title": "没有找到磁链接", 752 | "mag": "", 753 | "size": "0", 754 | "src": result.finalUrl, 755 | }); 756 | } 757 | cb(result.finalUrl, data); 758 | }, 759 | onerror: function (e) { 760 | console.error(e); 761 | throw "search error"; 762 | } 763 | }); 764 | }, 765 | 766 | }; 767 | 768 | 769 | let display_table = function (vid, insert_where) { 770 | common.add_style(); 771 | if (!document.querySelector("#nong-drive-anytime-dialog #nong-head")) { 772 | let tab_with_head = magnet_table.generate_head(); 773 | if (typeof insert_where === "string") { 774 | let elem = document.querySelector(insert_where); 775 | //console.log("display_table", tab, elem); 776 | if (elem) { 777 | elem.parentElement.insertBefore(tab_with_head, elem); 778 | } 779 | } else if (typeof insert_where === "function") { 780 | insert_where(tab_with_head); 781 | } else { 782 | console.error("插入表格错误"); 783 | return; 784 | } 785 | } else { 786 | let head = document.querySelector("#nong-drive-anytime-dialog #nong-head"); 787 | Array.from(document.querySelectorAll("#nong-drive-anytime-dialog .nong-row")).forEach(function (row) { 788 | if (row !== head) { 789 | row.parentElement.removeChild(row); 790 | } 791 | }); 792 | } 793 | my_search.current(vid, function (data, src) { 794 | let tab = magnet_table.generate(data, src); 795 | common.reg_event(); 796 | }); 797 | }; 798 | 799 | 800 | let dl_mode = function (v) { 801 | let mag = GM_getValue("magnet", ""); 802 | if (mag) { 803 | let script = document.createElement("script"); 804 | script.setAttribute("type", "text/javascript"); 805 | script.innerHTML = "(" + v.fill_form.toString() + ")(\"" + mag + "\")"; 806 | document.body.appendChild(script); 807 | } 808 | GM_setValue("magnet", ""); 809 | }; 810 | 811 | let run = function () { 812 | max_title_length = GM_getValue("max_title_length", 60); 813 | let main_keys = Object.keys(main); 814 | for (let i = 0; i < main_keys.length; i++) { 815 | let v = main[main_keys[i]]; 816 | if (v.re && v.re.test(location.href)) { 817 | if (v.type == 1) { 818 | dl_mode(v); 819 | } 820 | break; 821 | } 822 | } 823 | }; 824 | 825 | let max_title_length = GM_getValue("max_title_length", 40); 826 | let set_max_title_length = function () { 827 | let len = prompt("请输入你想要的标题长度", GM_getValue("max_title_length", 40)); 828 | if (len !== null && len !== "") { 829 | GM_setValue("max_title_length", len); 830 | run(); 831 | } 832 | }; 833 | let select_popup = function () { 834 | let enable = GM_getValue("enable_select_popup", false); 835 | if (enable) { 836 | document.body.addEventListener("mouseup", function (e) { 837 | if (unsafeWindow.getSelection().toString() !== "") { 838 | let elem = document.querySelector("#nong-drive-anytime-icon"); 839 | elem.style.left = e.clientX + "px"; 840 | elem.style.top = e.clientY + "px"; 841 | } 842 | //elem.style.position = "absolute"; 843 | }); 844 | document.body.addEventListener("mousedown", function (e) { 845 | if (e.target.id !== "nong-drive-anytime-icon") { 846 | let elem = document.querySelector("#nong-drive-anytime-icon"); 847 | elem.setAttribute("style", ""); 848 | } 849 | 850 | }); 851 | GM_registerMenuCommand("挊随时开车-关闭选中时弹出图标", function () { 852 | GM_setValue("enable_select_popup", false); }); 853 | } else { 854 | GM_registerMenuCommand("挊随时开车-开启选中时弹出图标", function () { 855 | GM_setValue("enable_select_popup", true); 856 | }); 857 | } 858 | }; 859 | GM_registerMenuCommand("挊随时开车-标题长度", set_max_title_length); 860 | 861 | select_popup(); 862 | run(); 863 | 864 | if (window === window.top) { 865 | i_am_old_driver.start(); 866 | } -------------------------------------------------------------------------------- /nong.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 挊 3 | // @namespace 撸 4 | // @description 自动获取磁链接并自动离线下载 5 | 6 | 7 | 8 | 9 | // @include http*://javkey.com/* 10 | // @include http*://avsox1.com/* 11 | // @include http*://avxo.pw/* 12 | // @include http*://www.av28.com/*/movie/* 13 | 14 | // @include http*://*javlibrary.com/* 15 | // @include http*://*javlib.com/* 16 | // @include http*://*javl10.com/* 17 | // @include http*://*19lib.com/* 18 | // @include http*://*j15av.com/* 19 | // @include http*://*d21b.com/* 20 | 21 | // @include http*://www.libredmm.com/movies/* 22 | 23 | // @include http*://www.javbus.com/* 24 | // @include http*://www.javbus.me/* 25 | // @include http*://www.javbus.in/* 26 | 27 | 28 | // @include http*://blog.jav4you.com/* 29 | // @include http*://*1pondo.tv/*/index.htm 30 | // @include http*://www.dmm.co.jp/digital/videoa/* 31 | // @include http*://www.jade-net-home.com/products/* 32 | 33 | // @include http*://pan.baidu.com/disk/home* 34 | // @include http*://115.com/?tab=offline&mode=wangpan 35 | // @include http*://www.furk.net/users/files/add 36 | 37 | // @version 1.51 38 | // @run-at document-end 39 | // @grant GM_xmlhttpRequest 40 | // @grant GM_setClipboard 41 | // @grant GM_setValue 42 | // @grant GM_getValue 43 | // @grant GM_addStyle 44 | // @grant GM_registerMenuCommand 45 | // ==/UserScript== 46 | 47 | var main = { 48 | //av信息查询 类 49 | jav: { 50 | type: 0, 51 | re: /(javmoo|avio|avso|avxo|av28|javkey|avsox1).*movie.*/, 52 | insert_where: "#movie-share", 53 | vid: function () { 54 | return document.querySelector(".header").nextElementSibling.innerHTML; 55 | } 56 | }, 57 | javlibrary: { 58 | type: 0, 59 | re: /(javlibrary|\d\dlib|jav\d\db|d21b).*\?v=.*/, 60 | insert_where: "#video_favorite_edit", 61 | vid: function () { 62 | return document.querySelector("#video_id").getElementsByClassName("text")[0].innerHTML; 63 | } 64 | }, 65 | javbus: { 66 | type: 0, 67 | re: /javbus/, 68 | insert_where: "#star-div", 69 | vid: function () { 70 | return document.querySelector(".header").nextElementSibling.textContent; 71 | } 72 | }, 73 | fanhaoku: { 74 | type: 0, 75 | re: /icpmp/, 76 | insert_where: ".mod_film", 77 | vid: function () { 78 | return document.querySelector(".title_inner").title; 79 | } 80 | }, 81 | libredmm: { 82 | type: 0, 83 | re: /libredmm/, 84 | insert_where: ".container", 85 | vid: function () { 86 | return location.href.match(/products\/(.*)/)[1]; 87 | } 88 | }, 89 | blogjav4you: { 90 | type: 0, 91 | re: /blog\.jav4you\.com/, 92 | insert_where: ".posttext", 93 | vid: function () { 94 | return document.querySelector(".posttitle a").textContent.match(/\[(.*)\]/)[1]; 95 | }, 96 | }, 97 | pondo1: { 98 | type: 0, 99 | re: /1pondo\.tv.*\/index.htm/, 100 | insert_where: ".hdg3", 101 | vid: function () { 102 | return location.pathname.split("/")[3]; 103 | }, 104 | }, 105 | jadenethome:{ 106 | type:0, 107 | re:/jade-net-home/, 108 | insert_where:".detailStory", 109 | vid:function(){ 110 | return document.querySelector("#detailRight dl dd").textContent; 111 | } 112 | }, 113 | dmm: { 114 | type: 0, 115 | re: /dmm\.co\.jp/, 116 | insert_where: ".lh4", 117 | vid: function () { 118 | var result = location.href.replace(/.*cid=/, "").replace(/\/\??.*/, "").match(/[^h_0-9].*/); 119 | return result[0] ? result[0].replace("00", "") : ""; 120 | } 121 | }, 122 | 123 | //网盘下载 类 124 | //这些 $ 是真正的 jquery 125 | baidu: { 126 | type: 1, 127 | re: /pan\.baidu\.com/, 128 | fill_form: function (magnet) { 129 | document.querySelector(".g-button[data-button-id=b13]").click(); 130 | setTimeout(function () { 131 | document.querySelector("#_disk_id_2").click(); 132 | setTimeout(function () { 133 | document.querySelector("#share-offline-link").value = magnet; 134 | document.querySelector(".g-button[data-button-id=b65]").click(); 135 | }, 500); 136 | }, 1500); 137 | } 138 | }, 139 | 115: { 140 | type: 1, 141 | re: /115\.com/, 142 | fill_form: function (link) { 143 | var rsc = setInterval(function () { 144 | if (document.readyState == "complete") { 145 | clearInterval(rsc); 146 | setTimeout(function () { 147 | Core["OFFL5Plug"].OpenLink(); 148 | setTimeout(function () { 149 | $("#js_offline_new_add").val(link); 150 | }, 300); 151 | }, 1000); 152 | } 153 | }, 400); 154 | } 155 | }, 156 | letv: { 157 | type: 1, 158 | re: /cloud\.letv\.com/, 159 | fill_form: function (link) { 160 | setTimeout(function () { 161 | $("#offline-btn").click(); 162 | setTimeout(function () { 163 | $("#offline_clear_complete").prev().click(); 164 | setTimeout(function () { 165 | $("#offline-add-link").val(link); 166 | }, 500); 167 | }, 1000); 168 | }, 2000); 169 | } 170 | }, 171 | furk: { 172 | type: 1, 173 | re: /www\.furk\.net/, 174 | fill_form: function (link) { 175 | setTimeout(function () { 176 | $("#url").val(link.replace("magnet:?xt=urn:btih:", "")); 177 | }, 1500); 178 | } 179 | }, 180 | 360: { 181 | type: 1, 182 | re: /yunpan\.360\.cn\/my/, 183 | fill_form: function (link) { 184 | yunpan.cmdCenter.showOfflineDia(); 185 | setTimeout(function () { 186 | $(".offdl-btn-create").click(); 187 | setTimeout(function () { 188 | $("#offdlUrl").val(link); 189 | }, 500); 190 | }, 1000); 191 | } 192 | }, 193 | uc: { 194 | type: 1, 195 | re: /disk\.yun\.uc\.cn\//, 196 | fill_form: function (link) { 197 | setTimeout(function () { 198 | $("#newuclxbtn_index").click(); 199 | setTimeout(function () { 200 | $("#uclxurl").val(link); 201 | }, 1000); 202 | }, 1200); 203 | } 204 | }, 205 | 206 | }; 207 | 208 | var offline_sites = { 209 | baidu: { 210 | url: "http://pan.baidu.com/disk/home", 211 | name: "百度云", 212 | enable: true 213 | }, 214 | 115: { 215 | name: "115离线", 216 | url: "http://115.com/?tab=offline&mode=wangpan", 217 | enable: true, 218 | }, 219 | varv: { 220 | name: "乐视云", 221 | url: "http://cloud.letv.com/webdisk/home/index", 222 | enable: false 223 | }, 224 | 360: { 225 | name: "360云", 226 | url: "http://yunpan.360.cn/my/", 227 | enable: false 228 | }, 229 | uc: { 230 | name: "UC离线", 231 | url: "http://disk.yun.uc.cn/", 232 | enable: false 233 | }, 234 | furk: { 235 | name: "Furk", 236 | url: "https://www.furk.net/users/files/add", 237 | enable: true 238 | }, 239 | }; 240 | var common = { 241 | add_style: function () { 242 | GM_addStyle([ 243 | "#nong-table{border-collapse: initial !important;background-color: white !important;text-align: center !important;margin:10px auto;color:#666 !important;font-size:13px;text-align:center !important;border: 1px solid #cfcfcf !important;border-radius: 10px !important;}", 244 | "#nong-table a {margin-right: 5px !important;color:blue}", 245 | "#nong-table a:hover {color:#d20f00 !important;}", 246 | "#nong-table th,#nong-table td{text-align: inherit !important;height:30px;padding:0 1em 0 !important;}", 247 | ".nong-row{text-align: inherit !important;height:30px;padding:0 1em 0 !important;border: 1px solid #EFEFEF !important;}", 248 | ".nong-row:hover{background-color: #dae8ff !important;}", 249 | ".nong-offline-download{color: rgb(0, 180, 30) !important;}", 250 | ".nong-offline-download:hover{color:red !important;}", 251 | ].join("")); 252 | }, 253 | handle_copy_event: function (event) { 254 | event.target.innerHTML = "成功"; 255 | GM_setClipboard(event.target.href); 256 | setTimeout(function () { 257 | event.target.innerHTML = "复制"; 258 | }, 1000); 259 | event.preventDefault(); //阻止跳转 260 | }, 261 | handle_dl_event: function (event) { 262 | var mag = event.target.parentElement.parentElement.parentElement.getAttribute("mag"); 263 | console.info("磁链接", mag); 264 | //console.log(0); 265 | GM_setValue("magnet", mag); 266 | }, 267 | 268 | reg_event: function () { 269 | var selector_event_map = [{ 270 | selector: ".nong-copy", 271 | type: "click", 272 | fn: this.handle_copy_event 273 | }, { 274 | selector: ".nong-offline-download", 275 | type: "click", 276 | fn: this.handle_dl_event 277 | }]; 278 | selector_event_map.forEach(function (obj) { 279 | Array.from(document.querySelectorAll(obj.selector)).forEach(function (elem) { 280 | elem.addEventListener(obj.type, obj.fn); 281 | }) 282 | }); 283 | /* 284 | for (var obj of selector_event_map) { 285 | for (var elem of document.querySelectorAll(obj.selector)) { 286 | //console.log(elem, obj.type, obj.fn); 287 | elem.addEventListener(obj.type, obj.fn); 288 | } 289 | }*/ 290 | }, 291 | parsetext: function (text) { 292 | var doc = null; 293 | try { 294 | doc = document.implementation.createHTMLDocument(""); 295 | doc.documentElement.innerHTML = text; 296 | return doc; 297 | } 298 | catch (e) { 299 | alert("parse error"); 300 | } 301 | }, 302 | }; 303 | var magnet_table = { 304 | template: { 305 | create_head: function (src) { 306 | var a = document.createElement("tr"); 307 | a.className = "nong-row"; 308 | a.id = "nong-head"; 309 | var head_str = [ 310 | "大小", 311 | "操作", 312 | "离线下载" 313 | ]; 314 | var th_list = [document.createElement("th"), document.createElement("th"), document.createElement("th"), document.createElement("th")]; 315 | 316 | var select_box = document.createElement("select"); 317 | var option_str = my_search.search_name_string; 318 | //console.log("get", GM_getValue("search_index")); 319 | var index = GM_getValue("search_index", 0); 320 | var op_value = 0; 321 | option_str.forEach(function (str) { 322 | var op = document.createElement("option"); 323 | op.value = op_value; 324 | op.textContent = str; 325 | if (index == op_value) { 326 | op.setAttribute("selected", "selected"); 327 | } 328 | op_value++; 329 | select_box.appendChild(op); 330 | }); 331 | /* 332 | for (var str of option_str) { 333 | var op = document.createElement("option"); 334 | op.value = op_value; 335 | op.textContent = str; 336 | if (index == op_value) { 337 | op.setAttribute("selected", "selected"); 338 | } 339 | op_value++; 340 | select_box.appendChild(op); 341 | }*/ 342 | select_box.addEventListener("change", function (e) { 343 | GM_setValue("search_index", this.value); 344 | run(); 345 | }); 346 | th_list[0].appendChild(select_box); 347 | 348 | th_list[1].appendChild(document.createElement("a")); 349 | th_list[1].lastChild.setAttribute("href", src); 350 | th_list[1].lastChild.setAttribute("target", "_blank"); 351 | th_list[1].lastChild.textContent = head_str[0]; 352 | 353 | th_list[2].appendChild(document.createElement("a")); 354 | th_list[2].lastChild.textContent = head_str[1]; 355 | 356 | th_list[3].appendChild(document.createElement("a")); 357 | th_list[3].lastChild.textContent = head_str[2]; 358 | 359 | th_list.forEach(function (th) { 360 | a.appendChild(th); 361 | }); 362 | /* 363 | for (var th of th_list) { 364 | a.appendChild(th); 365 | } 366 | */ 367 | return a; 368 | }, 369 | create_row: function (data) { 370 | var tr = document.createElement("tr"); 371 | tr.className = "nong-row"; 372 | tr.setAttribute("mag", data.mag); 373 | var td = document.createElement("td"); 374 | var list = [this.create_info(data.title, data.mag), this.create_size(data.size, data.src), this.create_operation(data.mag), this.create_offline()]; 375 | list.forEach(function (elem) { 376 | var c = td.cloneNode(true); 377 | c.appendChild(elem); 378 | tr.appendChild(c); 379 | }); 380 | /* 381 | for (var elem of [this.create_info(data.title, data.mag), this.create_size(data.size, data.src), this.create_operation(data.mag), this.create_offline()]) { 382 | var c = td.cloneNode(true); 383 | c.appendChild(elem); 384 | tr.appendChild(c); 385 | } 386 | */ 387 | return tr; 388 | }, 389 | create_row_for_sukebei: function (data) { 390 | var tr = document.createElement("tr"); 391 | tr.className = "nong-row"; 392 | tr.setAttribute("mag", data.mag); 393 | var td = document.createElement("td"); 394 | var append_elems = [ 395 | 396 | (function (title, src, self) { 397 | return self.create_info(title, src); 398 | })(data.title, data.src, this), 399 | 400 | (function (size, src, self) { 401 | return self.create_size(size, src); 402 | })(data.size, data.src, this), 403 | 404 | (function (torrent_url, self) { 405 | var operate = self.create_operation(torrent_url); 406 | operate.firstChild.textContent = "种子"; 407 | operate.firstChild.setAttribute("class", "nong-copy-sukebei"); 408 | operate.firstChild.setAttribute("target", "_blank"); 409 | return operate; 410 | })(data.torrent_url, this), 411 | 412 | (function (self) { 413 | var div = document.createElement("div"); 414 | div.textContent = "暂不支持离线下载"; 415 | return div; 416 | })(this)]; 417 | append_elems.forEach(function (elem) { 418 | var c = td.cloneNode(true); 419 | c.appendChild(elem); 420 | tr.appendChild(c); 421 | }); 422 | /* 423 | for (var elem of append_elems) { 424 | var c = td.cloneNode(true); 425 | c.appendChild(elem); 426 | tr.appendChild(c); 427 | } 428 | */ 429 | return tr; 430 | }, 431 | create_info: function (title, mag) { 432 | var a = this.info.cloneNode(true); 433 | a.firstChild.textContent = title.length < max_title_length ? title : title.substr(0, max_title_length) + "..."; 434 | a.firstChild.href = mag; 435 | a.title = title; 436 | return a; 437 | }, 438 | create_size: function (size, src) { 439 | var a = this.size.cloneNode(true); 440 | a.textContent = size; 441 | a.href = src; 442 | return a; 443 | }, 444 | create_operation: function (mag) { 445 | var a = this.operation.cloneNode(true); 446 | a.firstChild.href = mag; 447 | return a; 448 | }, 449 | create_offline: function () { 450 | var a = this.offline.cloneNode(true); 451 | a.className = "nong-offline"; 452 | return a; 453 | }, 454 | 455 | info: (function () { 456 | var a = document.createElement("div"); 457 | var b = document.createElement("a"); 458 | b.textContent = "name"; 459 | b.href = "src"; 460 | b.target = "_blank"; 461 | a.appendChild(b); 462 | return a; 463 | })(), 464 | size: function () { 465 | var a = document.createElement("a"); 466 | a.textContent = "size"; 467 | a.target = "_blank"; 468 | return a; 469 | }(), 470 | operation: (function () { 471 | var a = document.createElement("div"); 472 | var copy = document.createElement("a"); 473 | copy.className = "nong-copy"; 474 | copy.textContent = "复制"; 475 | a.appendChild(copy); 476 | return a; 477 | })(), 478 | offline: (function () { 479 | var a = document.createElement("div"); 480 | var b = document.createElement("a"); 481 | b.className = "nong-offline-download"; 482 | b.target = "_blank"; 483 | for (var k in offline_sites) { 484 | if (offline_sites[k].enable) { 485 | var c = b.cloneNode(true); 486 | c.href = offline_sites[k].url; 487 | c.textContent = offline_sites[k].name; 488 | a.appendChild(c); 489 | } 490 | } 491 | return a; 492 | })(), 493 | }, 494 | generate_head: function () { 495 | var tab = document.createElement("table"); 496 | tab.id = "nong-table"; 497 | tab.appendChild(this.template.create_head("https://greasyfork.org/zh-CN/scripts/8392-%E6%8C%8A")); 498 | return tab; 499 | }, 500 | generate: function (src, data) { 501 | //console.log(src); 502 | //console.log(data); 503 | var tab = document.querySelector("#nong-table"); 504 | tab.querySelector("#nong-head th a").href = src; 505 | if (src.match("nyaa.si")) { 506 | data.forEach((d) => { 507 | tab.appendChild(this.template.create_row_for_sukebei(d)); 508 | }); 509 | /* 510 | for (var d of data) { 511 | tab.appendChild(this.template.create_row_for_sukebei(d)); 512 | } 513 | */ 514 | } 515 | else { 516 | data.forEach((d) => { 517 | tab.appendChild(this.template.create_row(d)); 518 | }); 519 | /* 520 | for (var d of data) { 521 | tab.appendChild(this.template.create_row(d)); 522 | } 523 | */ 524 | } 525 | return tab; 526 | }, 527 | 528 | }; 529 | var my_search = { 530 | current: function (kw, cb) { 531 | var search = my_search[GM_getValue("search_index", 0)]; 532 | try { 533 | return search(kw, cb); 534 | } 535 | catch (e) { 536 | this.search_error(); 537 | } 538 | }, 539 | search_error: function (r) { 540 | alert("搜索出现错误,请检查网络"); 541 | }, 542 | search_name_string: ["btso", "btdb", "nyaa.si", "btkitty","torrentkitty","btlibrary"], 543 | 0: function (kw, cb) { 544 | GM_xmlhttpRequest({ 545 | method: "GET", 546 | url: "https://btso.pw/search/" + kw, 547 | onload: function (result) { 548 | let doc = common.parsetext(result.responseText); 549 | let data = []; 550 | let t = doc.getElementsByClassName("data-list")[0]; 551 | if (t) { 552 | for (let elem of t.getElementsByTagName("a")) { 553 | if (!elem.className.match("btn")) { 554 | data.push({ 555 | "title": elem.title, 556 | "mag": "magnet:?xt=urn:btih:" + elem.outerHTML.replace(/.*hash\//, "").replace(/" .*\n.*\n.*\n.*/, ""), 557 | "size": elem.nextElementSibling.textContent, 558 | "src": elem.href, 559 | }); 560 | } 561 | } 562 | } 563 | else { 564 | data.push({ 565 | "title": "没有找到磁链接", 566 | "mag": "", 567 | "size": "0", 568 | "src": result.finalUrl, 569 | }); 570 | } 571 | cb(result.finalUrl, data); 572 | }, 573 | onerror: function (e) { 574 | console.error(e); 575 | throw "search error"; 576 | } 577 | }); 578 | }, 579 | 1: function (kw, cb) { 580 | GM_xmlhttpRequest({ 581 | method: "GET", 582 | url: "http://btdb.to/q/" + kw + "/", 583 | onload: function (result) { 584 | let doc = common.parsetext(result.responseText); 585 | let data = []; 586 | let t = doc.getElementsByClassName("item-title"); 587 | if (t) { 588 | for (let elem of t) { 589 | data.push({ 590 | "title": elem.firstChild.title, 591 | "mag": elem.nextElementSibling.firstElementChild.href, 592 | "size": elem.nextElementSibling.children[1].textContent, 593 | "src": "https://btdb.in" + elem.firstChild.getAttribute("href"), 594 | }); 595 | } 596 | } 597 | else { 598 | data.push({ 599 | "title": "没有找到磁链接", 600 | "mag": "", 601 | "size": "0", 602 | "src": result.finalUrl, 603 | }); 604 | } 605 | 606 | cb(result.finalUrl, data); 607 | }, 608 | onerror: function (e) { 609 | console.error(e); 610 | throw "search error"; 611 | } 612 | }); 613 | }, 614 | 2: function (kw, cb) { 615 | GM_xmlhttpRequest({ 616 | method: "GET", 617 | url: "https://sukebei.nyaa.si/?f=0&c=0_0&q=" + kw, 618 | onload: function (result) { 619 | let doc = common.parsetext(result.responseText); 620 | let data = []; 621 | let t = doc.querySelectorAll("tr.default"); 622 | if (t.length!==0) { 623 | for (let elem of t) { 624 | data.push({ 625 | "title": elem.querySelector("td:nth-child(2)>a:nth-child(1)").title, 626 | "mag": "", 627 | "torrent_url": "https://nyaa.si" + elem.querySelector("td:nth-child(3)>a:nth-child(1)").href, 628 | "size": elem.querySelector("td:nth-child(4)").textContent, 629 | "src": "https://nyaa.si" + elem.querySelector("td:nth-child(2)>a:nth-child(1)").href, 630 | }); 631 | } 632 | } 633 | else { 634 | data.push({ 635 | "title": "没有找到磁链接", 636 | "mag": "", 637 | "torrent_url": "", 638 | "size": "0", 639 | "src": result.finalUrl, 640 | }); 641 | } 642 | 643 | cb(result.finalUrl, data); 644 | }, 645 | onerror: function (e) { 646 | console.error(e); 647 | throw "search error"; 648 | } 649 | }); 650 | }, 651 | 3: function (kw, cb) { 652 | GM_xmlhttpRequest({ 653 | method: "POST", 654 | url: "http://btkitty.pet/", 655 | data: "keyword=" + kw+"&hidden=true", 656 | headers: { 657 | "Content-Type": "application/x-www-form-urlencoded" 658 | }, 659 | onload: function (result) { 660 | let doc = common.parsetext(result.responseText); 661 | let data = []; 662 | let t = doc.getElementsByClassName("list-con"); 663 | if (t) { 664 | for (let elem of t) { 665 | data.push({ 666 | "title": elem.querySelector("dt a").textContent, 667 | "mag": elem.querySelector("dd a").href, 668 | "size": elem.querySelector(".option span:nth-child(3) b").textContent, 669 | "src": elem.querySelector("dt a").href, 670 | }); 671 | } 672 | } 673 | else { 674 | data.push({ 675 | "title": "没有找到磁链接", 676 | "mag": "", 677 | "size": "0", 678 | "src": result.finalUrl, 679 | }); 680 | } 681 | cb(result.finalUrl, data); 682 | }, 683 | onerror: function (e) { 684 | console.error(e); 685 | throw "search error"; 686 | } 687 | }); 688 | }, 689 | 4: function (kw, cb) { 690 | GM_xmlhttpRequest({ 691 | method: "GET", 692 | url: "https://www.torrentkitty.tv/search/"+kw, 693 | onload: function (result) { 694 | let doc = common.parsetext(result.responseText); 695 | let data = []; 696 | let t = doc.querySelectorAll("#archiveResult tr"); 697 | if (t) { 698 | t = Array.slice(t,1,t.length) 699 | for (let elem of t) { 700 | data.push({ 701 | "title": elem.querySelector(".name").textContent, 702 | "mag": elem.querySelector(".action>a:nth-child(2)").href, 703 | "size": elem.querySelector(".size").textContent, 704 | "src": elem.querySelector(".action>a:nth-child(1)").href, 705 | }); 706 | } 707 | } 708 | else { 709 | data.push({ 710 | "title": "没有找到磁链接", 711 | "mag": "", 712 | "size": "0", 713 | "src": result.finalUrl, 714 | }); 715 | } 716 | cb(result.finalUrl, data); 717 | }, 718 | onerror: function (e) { 719 | console.error(e); 720 | throw "search error"; 721 | } 722 | }); 723 | }, 724 | 5: function (kw, cb) { 725 | GM_xmlhttpRequest({ 726 | method: "POST", 727 | url: "http://btlibrary.pw", 728 | data: "keyword=" + kw, 729 | headers: { 730 | "Content-Type": "application/x-www-form-urlencoded" 731 | }, 732 | onload: function (result) { 733 | let doc = common.parsetext(result.responseText); 734 | let data = []; 735 | let t = doc.querySelectorAll(".item"); 736 | if (t) { 737 | for (let elem of t) { 738 | data.push({ 739 | "title": elem.querySelector(".item-title>a").textContent, 740 | "mag": elem.querySelector(".item-detail>span:nth-child(1)>a").href, 741 | "size": elem.querySelector(".item-detail>span:nth-child(3)>b").textContent, 742 | "src": elem.querySelector(".item-title>a").href, 743 | }); 744 | } 745 | } 746 | else { 747 | data.push({ 748 | "title": "没有找到磁链接", 749 | "mag": "", 750 | "size": "0", 751 | "src": result.finalUrl, 752 | }); 753 | } 754 | cb(result.finalUrl, data); 755 | }, 756 | onerror: function (e) { 757 | console.error(e); 758 | throw "search error"; 759 | } 760 | }); 761 | }, 762 | }; 763 | 764 | var display_table = function (vid, insert_where) { 765 | common.add_style(); 766 | if (!document.querySelector("#nong-head")) { 767 | var tab_with_head = magnet_table.generate_head(); 768 | if (typeof insert_where === "string") { 769 | var elem = document.querySelector(insert_where); 770 | //console.log("display_table", tab, elem); 771 | if (elem) { 772 | elem.parentElement.insertBefore(tab_with_head, elem); 773 | } 774 | } 775 | else if (typeof insert_where === "function") { 776 | insert_where(tab_with_head); 777 | } 778 | else { 779 | console.error("插入表格错误"); 780 | return; 781 | } 782 | } 783 | else { 784 | var head = document.querySelector("#nong-head"); 785 | Array.from(document.querySelectorAll(".nong-row")).forEach(function (row) { 786 | if (row !== head) { 787 | row.parentElement.removeChild(row); 788 | } 789 | }); 790 | } 791 | my_search.current(vid, function (data, src) { 792 | var tab = magnet_table.generate(data, src); 793 | common.reg_event(); 794 | }); 795 | }; 796 | 797 | var vid_mode = function (v) { 798 | var vid = ""; 799 | try { 800 | vid = v.vid(); 801 | } 802 | catch (error) { 803 | vid = ""; 804 | console.error("没有找到番号", v.vid.toString()); 805 | } 806 | if (vid) { 807 | console.info("番号:", vid); 808 | display_table(vid, v.insert_where); 809 | } 810 | }; 811 | 812 | var dl_mode = function (v) { 813 | 814 | var mag = GM_getValue("magnet", ""); 815 | //console.info(1, "开始离线下载", mag); 816 | if (mag) { 817 | var script = document.createElement("script"); 818 | script.setAttribute("type", "text/javascript"); 819 | script.innerHTML = "(" + v.fill_form.toString() + ")(\"" + mag + "\")"; 820 | document.body.appendChild(script); 821 | //console.info(info); 822 | } 823 | GM_setValue("magnet", ""); 824 | }; 825 | 826 | var run = function () { 827 | max_title_length = GM_getValue("max_title_length", 40); 828 | var main_keys = Object.keys(main); 829 | for (var i = 0; i < main_keys.length; i++) { 830 | var v = main[main_keys[i]]; 831 | 832 | if (v.re && v.re.test(location.href)) { 833 | if (v.type === 0) { 834 | 835 | //---- 836 | 837 | //for javlibrary 838 | if (main_keys[i] === "javlibrary") { 839 | if (document.querySelector("#adultwarningprompt")) { 840 | document.querySelectorAll("#adultwarningprompt input")[0].click(); 841 | } 842 | } 843 | //---- 844 | 845 | vid_mode(v); 846 | } 847 | else if (v.type == 1) { 848 | dl_mode(v); 849 | } 850 | break; 851 | } 852 | } 853 | }; 854 | var max_title_length = GM_getValue("max_title_length", 40); 855 | var set_max_title_length = function () { 856 | var len = prompt("请输入你想要的标题长度", GM_getValue("max_title_length", 40)); 857 | if (len !== null && len !== "") { 858 | GM_setValue("max_title_length", len); 859 | run(); 860 | } 861 | }; 862 | 863 | GM_registerMenuCommand("挊-标题长度", set_max_title_length); 864 | run(); 865 | 866 | 867 | 868 | --------------------------------------------------------------------------------