FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SyncnextUserScriptHelper/SyncnextUserscriptHelper.user.js at main · qoli/SyncnextUserScriptHelper · GitHub
qoli
/
SyncnextUserScriptHelper
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
SyncnextUserScriptHelper
/
SyncnextUserscriptHelper.user.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
102 lines (85 loc) · 2.63 KB
Breadcrumbs
SyncnextUserScriptHelper
/
SyncnextUserscriptHelper.user.js
Copy path
File metadata and controls
102 lines (85 loc) · 2.63 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
// ==UserScript==
//
@name
Syncnext 網頁解釋助手
//
@namespace
http://syncnext_ronnie.com/
//
@version
1.0
//
@description
發送網頁解釋結果給 Syncnext tvOS app
//
@author
Ronnie Wong
//
@match
*://*/*
//
@grant
GM.getValue
//
@grant
GM.setValue
//
@grant
GM_getValue
//
@grant
GM_setValue
//
@grant
GM.xmlHttpRequest
//
@grant
GM_xmlhttpRequest
//
@inject
-into content
//
@run
-at document-end
//
@downloadURL
https://raw.githubusercontent.com/qoli/SyncnextUserScriptHelper/main/SyncnextUserscriptHelper.user.js
// ==/UserScript==
(
async
function
(
)
{
"use strict"
;
GM_xmlhttpRequest
(
{
method
:
"HEAD"
,
url
:
window
.
location
.
href
,
onload
:
async
function
(
response
)
{
console
.
log
(
response
.
status
)
;
if
(
response
.
status
!=
200
)
{
const
newPostURL
=
await
GM
.
getValue
(
"postURL"
,
null
)
;
console
.
log
(
"網頁錯誤代碼:"
+
response
.
status
)
;
if
(
newPostURL
!=
null
)
{
getError
(
newPostURL
,
response
.
status
)
;
}
return
;
}
const
syncnextBody
=
document
.
getElementById
(
"_syncnextScript"
)
;
if
(
syncnextBody
!=
null
)
{
syncnextBody
.
classList
.
remove
(
"scriptNotInstalled"
)
;
syncnextBody
.
classList
.
add
(
"scriptInstalled"
)
;
}
const
postURL
=
document
.
getElementById
(
"_syncnextURL"
)
;
const
pageURL
=
document
.
getElementById
(
"_syncnextPageURL"
)
;
if
(
postURL
!=
null
&&
pageURL
!=
null
)
{
await
GM
.
setValue
(
"postURL"
,
postURL
.
innerHTML
)
;
await
GM
.
setValue
(
"pageURL"
,
pageURL
.
innerHTML
)
;
}
const
videoUrls
=
document
.
querySelectorAll
(
"video[src], video source[src]"
)
;
if
(
videoUrls
.
length
==
0
)
{
return
;
}
videoUrls
.
forEach
(
async
function
(
video
)
{
const
url
=
video
.
currentSrc
||
video
.
src
;
if
(
url
!==
undefined
)
{
const
postURL
=
await
GM
.
getValue
(
"postURL"
,
null
)
;
const
pageURL
=
await
GM
.
getValue
(
"pageURL"
,
null
)
;
if
(
postURL
!==
null
&&
pageURL
!==
null
)
{
getRequest
(
postURL
,
url
,
pageURL
)
;
}
}
}
)
;
}
,
}
)
;
}
)
(
)
;
function
getRequest
(
postURL
,
url
,
pageURL
)
{
const
xmlURL
=
postURL
+
"/receiver"
+
"?page="
+
encodeURIComponent
(
pageURL
)
+
"&video="
+
encodeURIComponent
(
url
)
;
GM_xmlhttpRequest
(
{
method
:
"GET"
,
url
:
xmlURL
,
}
)
;
}
function
getError
(
postURL
,
text
)
{
const
xmlURL
=
postURL
+
"/error"
+
"?error="
+
text
;
GM_xmlhttpRequest
(
{
method
:
"GET"
,
url
:
xmlURL
,
onload
:
function
(
res
)
{
console
.
log
(
res
.
responseText
)
;
}
,
}
)
;
}
Back
|
FazBrowse Home
|
New Git URL