-
Notifications
You must be signed in to change notification settings - Fork 0
/
dytt.js
131 lines (91 loc) · 3.4 KB
/
dytt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// ==UserScript==
// @name 电影天堂复制磁链
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 点击复制电影、电视剧链接;添加一键复制全集电视剧链接
// @author 花花nice
// @match *://www.ygdy8.com/*
// @match *://dy.dytt8.net/*
// @match https://dy.dytt8.net/
// @match https://www.ygdy8.com/
// @grant none
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js
// @require https://cdn.bootcdn.net/ajax/libs/Base64/1.1.0/base64.js
// @updateURL https://raw.githubusercontent.com/hhnice510/TamperMonkey/main/dytt.js
// @updateURL https://gitee.com/hhnice/TamperMonkey/raw/main/dytt.js
// @license MIT
// ==/UserScript==
$(function(){
console.log("引入成功")
});
//var num = $("#Zoom").find("table").length
var num = $("#Zoom span table").length;
console.log("一共" + num + "集");
//判断当前页面为电影还是电视剧
var isMovie = e => {
return 0 === num ? true : false;
}
var isTv = e => {
return 1 <= num ? true : false;
}
if(isMovie()){
let clipboard = ' ';
let element = document.querySelector('#Zoom > span > a');
let magnet = element.attributes["href"].nodeValue;
let btn = document.createElement('button');
btn.innerText = '复制链接';
element.before(btn);
btn.addEventListener('click', copyMagnet);
function copyMagnet() {
clipboard = navigator.clipboard.writeText(magnet)
console.log("复制成功")
//alert("复制成功")
};
}
if(isTv()){
var allLinks = [];
for(var i = 4; i < num + 4; i++){
//获取标签文本 -srt
let $i = i;
let $element = $('#Zoom > span > table:nth-child(' + $i + ') > tbody > tr > td > a')
let srt = $element.text();
//url 编码 encodeURI(URL)
let ftp = encodeURI(srt);
//console.log(ftp)
let url = 'AA' + ftp + 'ZZ';
//base64编码
//官方cdn中 Base64.js编码方式为btoa(srt)
//jquery.base64.js中,编码方式为$.base64.encode(srt)
let urlBase64 = btoa(url);
let thunder = 'thunder://' + urlBase64;
//console.log(thunder);
//将thunder输出至数组存储
allLinks.push(thunder);
let id = $i - 3;
//添加单集复制按钮,放置在链接前面
let btn = document.createElement('button'); btn.setAttribute("id", id); btn.innerText = '复制链接'; $element.before(btn);
//定义剪贴板 添加监控click点击复制事件
let clipboard = '';
btn.addEventListener('click', copyThunder);
function copyThunder(){
clipboard = navigator.clipboard.writeText(thunder)
console.log("第" + id + "集复制成功")
}
}
//console.log(allLinks)
let $element1 = $('#Zoom > span > p:nth-child(3) > strong > font');
let btn1 = document.createElement('button');
btn1.innerText = '一键复制';
$element1.after(btn1);
btn1.addEventListener('click', copyAllLinks);
//将数组链接换行输出存储
var all ='';
for(var x = 0; x < num; x++){
all +=allLinks[x] + '\r';
}
function copyAllLinks(){
//let all = allLinks[0]+ '\r' +allLinks[1]
let clipboard1 = navigator.clipboard.writeText(all)
console.log("一键复制成功")
}
}