Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tools
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
tools
Commits
6f30458a
Commit
6f30458a
authored
Dec 08, 2022
by
庄欣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限判断
parent
d089158f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
20 deletions
+75
-20
mp-downloader/manifest.json
+7
-1
mp-downloader/static/js/index.js
+67
-18
mp-remark/js/background.js
+1
-1
No files found.
mp-downloader/manifest.json
View file @
6f30458a
...
...
@@ -4,8 +4,14 @@
"description"
:
"米拍下图工具"
,
"version"
:
"1.0"
,
"permissions"
:
[
"tabs"
"tabs"
,
"webRequest"
,
"cookies"
,
"*://*.mepai.me/"
],
"background"
:
{
"scripts"
:
[
"background.js"
]
},
"content_scripts"
:
[
{
"matches"
:
[
"https://www.mepai.me/works/*"
,
"https://www.photosaas.cn/*"
],
...
...
mp-downloader/static/js/index.js
View file @
6f30458a
...
...
@@ -9,7 +9,7 @@ setInterval(function () {
},
1000
);
var
body
=
$
(
"#__nuxt"
);
var
accessToken
=
""
;
var
img
=
new
Image
();
var
checkedProp
=
false
;
img
.
src
=
chrome
.
extension
.
getURL
(
"ui.html"
);
...
...
@@ -138,7 +138,7 @@ function setSelect(dom, all) {
}
function
getImages
()
{
var
worksId
;
var
worksId
=
getWorksId
()
;
var
userNickname
;
var
userId
=
""
;
var
lists
=
[];
...
...
@@ -148,18 +148,6 @@ function getImages() {
lists
=
$
(
".swiper-wrapper"
).
find
(
"img"
);
var
urls
=
[];
var
imgSrc
=
""
;
var
worksString
=
window
.
location
.
href
if
(
worksString
.
length
>
0
&&
worksString
.
indexOf
(
"works"
)
>
-
1
)
{
var
start
=
worksString
.
indexOf
(
"works/"
)
+
"works/"
.
length
;
var
end
=
worksString
.
indexOf
(
"?"
);
if
(
end
<=
-
1
)
{
end
=
worksString
.
length
;
}
var
worksId
=
worksString
.
substring
(
start
,
end
)
if
(
isNaN
(
worksId
))
{
worksId
=
base64Decode
(
worksId
);
}
}
userNickname
=
$
(
$
(
".user-info > span.nickname"
)[
0
]).
text
();
$
.
each
(
lists
,
(
i
,
n
)
=>
{
let
fullUrl
=
n
.
currentSrc
;
...
...
@@ -201,6 +189,22 @@ function getImages() {
return
images
;
}
function
getWorksId
()
{
var
worksString
=
window
.
location
.
href
if
(
worksString
.
length
>
0
&&
worksString
.
indexOf
(
"works"
)
>
-
1
)
{
var
start
=
worksString
.
indexOf
(
"works/"
)
+
"works/"
.
length
;
var
end
=
worksString
.
indexOf
(
"?"
);
if
(
end
<=
-
1
)
{
end
=
worksString
.
length
;
}
var
worksId
=
worksString
.
substring
(
start
,
end
)
if
(
isNaN
(
worksId
))
{
worksId
=
base64Decode
(
worksId
);
}
}
return
worksId
;
}
function
base64Decode
(
input
){
rv
=
window
.
atob
(
input
);
rv
=
escape
(
rv
);
...
...
@@ -243,8 +247,14 @@ function changeFocus() {
function
downloadAll
()
{
if
(
confirm
(
"点击确定开始下载!"
))
{
var
q
=
$
(
"select[name=quality]"
).
val
();
var
uris
=
[];
$
.
each
(
$
(
body
).
find
(
"input[type='checkbox']:checked"
),
(
i
,
n
)
=>
{
var
src
=
$
(
n
).
val
();
uris
.
push
(
$
(
n
).
val
().
replace
(
"https://images.mepai.me"
,
""
));
})
getRawPath
(
getWorksId
(),
uris
,
function
(
data
)
{
var
j
=
0
;
for
(
var
i
in
uris
)
{
var
src
=
data
[
uris
[
i
]];
var
isVideo
=
false
;
if
(
src
.
indexOf
(
".mp4"
)
>
-
1
)
{
isVideo
=
true
;
...
...
@@ -264,14 +274,17 @@ function downloadAll() {
}
ext
=
"!1200w.jpg"
}
var
downloadUrl
=
$
(
n
).
val
()
+
ext
;
var
downloadUrl
=
src
+
ext
;
var
n
=
$
(
body
).
find
(
"input[type='checkbox']:checked"
)[
j
];
if
(
isVideo
)
{
$
.
getJSON
(
"https://api.mepai.me/goms/video/sign?path="
+
downloadUrl
,
function
(
res
)
{
downloadResource
(
res
.
data
,
$
(
n
).
attr
(
"fileid"
)
+
"-"
+
q
,
true
,
$
(
n
));
})
}
else
{
downloadResource
(
downloadUrl
,
$
(
n
).
attr
(
"fileid"
)
+
"-"
+
q
,
false
,
null
);
downloadResource
(
"https://images.mepai.me"
+
downloadUrl
,
$
(
n
).
attr
(
"fileid"
)
+
"-"
+
q
,
false
,
null
);
}
j
++
;
};
});
}
}
...
...
@@ -337,7 +350,29 @@ function bindChangeWorkEvents() {
return
false
;
}
function
getRawPath
(
worksId
,
srcs
,
callback
)
{
$
.
ajax
({
type
:
"post"
,
url
:
'https://api.mepai.me/goms/parse-src'
,
async
:
true
,
// 使用同步方式
data
:
JSON
.
stringify
(
{
'works_id'
:
parseInt
(
worksId
),
'uris'
:
srcs
,
}),
headers
:
{
"accesstoken"
:
accessToken
},
contentType
:
"application/json; charset=utf-8"
,
dataType
:
"json"
,
success
:
function
(
res
)
{
if
(
res
.
code
.
toString
()
!=
"100001"
)
{
alert
(
"用户未登录,请确认您的权限!"
);
return
;
}
callback
(
res
.
data
);
}
});
}
function
bindChangeImg
()
{
$
(
".btn-next"
).
click
(()
=>
{
...
...
@@ -347,3 +382,16 @@ function bindChangeImg() {
changeFocus
();
})
}
chrome
.
extension
.
sendRequest
({},
function
(
response
)
{
accessToken
=
response
.
access_token
;
});
function
getCookie
(
key
,
callback
)
{
chrome
.
runtime
.
sendMessage
({
"action"
:
"getCookie"
,
"key"
:
key
,
},
function
(
response
)
{
callback
(
response
);
});
}
\ No newline at end of file
mp-remark/js/background.js
View file @
6f30458a
chrome
.
extension
.
onRequest
.
addListener
(
function
(
request
,
sender
,
sendResponse
)
{
function
(
request
,
sender
,
sendResponse
)
{
chrome
.
cookies
.
get
({
url
:
"https://www.mepai.me/"
,
name
:
"auth"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment