FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
userscript/scripts/Flvxz.user.js at master · dadachugeng/userscript · GitHub
dadachugeng
userscript
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
userscript
/
scripts
/
Flvxz.user.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
165 lines (141 loc) · 4.72 KB
Breadcrumbs
userscript
/
scripts
/
Flvxz.user.js
Copy path
File metadata and controls
165 lines (141 loc) · 4.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// ==UserScript==
//
@name
Flvxz
//
@namespace
https://github.com/ywzhaiqi
//
@version
0.1
//
@description
flvxz.com 复制到剪贴板或使用 IDM 下载。其中 "用 IDM 下载" 需要注册协议,配合 addToIDM.ahk 实现。
//
@include
http://*flvxz.com/?url=*
//
@include
http://*flv.cn/?url=*
//
@grant
GM_setClipboard
//
@require
http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js
//
@noframes
// ==/UserScript==
var
noReferrerHost
=
[
'www.56.com'
]
;
function
init
(
)
{
var
locationHref
=
location
.
href
;
var
isNoReferer
=
noReferrerHost
.
some
(
function
(
host
)
{
return
locationHref
.
indexOf
(
host
)
!=
-
1
;
}
)
;
if
(
isNoReferer
)
{
alert
(
'该站点为 noreferer 下载,需要点击一次下载链接才能成功下载'
)
;
return
;
}
// 添加导出按钮
var
$result
=
$
(
'#result'
)
;
var
observer
=
new
MutationObserver
(
function
(
)
{
$result
.
find
(
'span.quality:contains("[")'
)
.
each
(
function
(
)
{
var
$sep
=
$
(
this
)
ul
=
$sep
.
prev
(
)
.
find
(
'ul'
)
;
$
(
'<li>'
)
.
append
(
$
(
'<a href="javascript:void">复制到剪贴板</a>'
)
.
click
(
function
(
)
{
copyLinks
(
$sep
[
0
]
.
textContent
)
;
}
)
)
.
appendTo
(
ul
)
;
$
(
'<li>'
)
.
append
(
$
(
'<a href="javascript:void">用 IDM 下载</a>'
)
.
click
(
function
(
)
{
launchIDM
(
$sep
[
0
]
.
textContent
)
;
}
)
)
.
appendTo
(
ul
)
;
// $('<li>')
// .append($('<a href="javascript:void">IDM 格式导出</a>').click(function() {
// exportIDM($sep[0].textContent);
// }))
// .appendTo(ul);
}
)
;
observer
.
disconnect
(
)
;
}
)
;
observer
.
observe
(
$result
[
0
]
,
{
childList
:
true
}
)
;
}
function
copyLinks
(
type
)
{
var
data
=
getData
(
type
)
;
if
(
data
)
{
var
str
=
data
.
map
(
function
(
i
)
{
return
i
.
title
+
'\r\n'
+
i
.
url
;
}
)
.
join
(
'\r\n'
)
;
GM_setClipboard
(
str
)
;
alerts
(
'已复制 '
+
data
.
length
+
' 个链接到剪贴板'
,
2000
)
;
}
}
function
launchIDM
(
type
)
{
var
data
=
getData
(
type
)
;
if
(
data
)
{
var
str
=
data
.
map
(
function
(
i
)
{
return
i
.
title
+
'\r\n'
+
i
.
url
;
}
)
.
join
(
'\r\n'
)
;
GM_setClipboard
(
str
)
;
location
.
href
=
'idm://clipboard'
;
}
}
function
exportIDM
(
type
)
{
var
data
=
getData
(
type
)
;
if
(
data
)
{
var
str
=
''
;
$
(
data
)
.
each
(
function
(
)
{
str
+=
'<\r\n'
+
this
.
url
+
'\r\n'
+
this
.
title
+
'\r\n>\r\n'
;
}
)
;
var
title
=
$
(
'.media-heading'
)
.
text
(
)
;
saveAs
(
str
,
title
+
'.ef2'
)
}
}
function
getData
(
type
)
{
var
linkHash
=
getLinkHash
(
)
;
var
arr
=
linkHash
[
type
]
;
if
(
arr
)
{
return
arr
;
}
else
{
console
.
error
(
'找不到当前类型的视频'
,
sep
)
;
}
}
function
getLinkHash
(
isNoReferer
)
{
// 根据类型对所有链接进行分类
var
linkHash
=
{
}
,
curArr
;
// 分段和链接
$
(
'span[style="color:red"]:contains("["), #result > a[rel="noreferrer"], #result > div > a[rel="noreferrer"]'
)
.
each
(
function
(
i
,
el
)
{
var
$el
=
$
(
this
)
;
if
(
el
.
nodeName
==
'SPAN'
)
{
curArr
=
linkHash
[
el
.
textContent
]
=
[
]
;
}
else
{
var
url
=
$el
.
attr
(
'href'
)
;
if
(
isNoReferer
)
{
url
=
'https://noreferer.flvxz.com/'
+
url
.
replace
(
/
^
h
t
t
p
s
?
:
\/
\/
/
i
,
''
)
;
}
curArr
.
push
(
{
title
:
safeTitle
(
$el
.
text
(
)
)
,
url
:
url
}
)
;
}
}
)
;
return
linkHash
;
}
function
safeTitle
(
title
)
{
return
title
.
replace
(
/
[
\\
\|
\:
\*
\"
\?
\<
\>
]
/
g
,
"_"
)
;
}
function
saveAs
(
data
,
filename
)
{
var
blob
=
new
Blob
(
[
data
]
,
{
type
:
'application/octet-stream'
}
)
;
var
url
=
window
.
URL
.
createObjectURL
(
blob
)
;
var
saveas
=
document
.
createElement
(
'a'
)
;
saveas
.
href
=
url
;
saveas
.
style
.
display
=
'none'
;
document
.
body
.
appendChild
(
saveas
)
;
saveas
.
download
=
filename
;
saveas
.
click
(
)
;
setTimeout
(
function
(
)
{
saveas
.
parentNode
.
removeChild
(
saveas
)
;
}
,
1000
)
document
.
addEventListener
(
'unload'
,
function
(
)
{
window
.
URL
.
revokeObjectURL
(
url
)
;
}
)
;
}
function
alerts
(
msg
,
closeTime
)
{
var
div
=
alerts
.
div
;
if
(
!
div
)
{
div
=
alerts
.
div
=
document
.
createElement
(
'div'
)
;
div
.
style
.
cssText
=
'position:fixed;z-index:1001;top:10%;left:40%;background: #F9EDBE;box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.5);border: 1px solid #FBDA91;padding: 5px;'
;
document
.
body
.
appendChild
(
div
)
;
}
div
.
innerHTML
=
msg
;
div
.
style
.
display
=
'block'
;
setTimeout
(
function
(
)
{
div
.
style
.
display
=
'none'
;
}
,
closeTime
||
2000
)
;
}
init
(
)
;
Back
|
FazBrowse Home
|
New Git URL