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
bc76441e
Commit
bc76441e
authored
Dec 23, 2020
by
庄欣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成
parent
fcf1d19f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
89 deletions
+150
-89
README.md
+2
-2
mp-downloader/static/js/index.js
+30
-9
mp-downloader/ui.html
+17
-3
nginx-ext/docker-compose.yaml
+3
-2
nginx-ext/filter.conf
+0
-73
nginx-ext/test.conf
+98
-0
No files found.
README.md
View file @
bc76441e
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
### mp-downloader
### mp-downloader
chrome插件项目,用于米拍官方网站作品详情页的下载工具
chrome插件项目,用于米拍官方网站作品详情页的下载工具
### nginx-ext
### nginx-ext
使用openrsty开发的在nginx层面拦截验证发送短信请求有效性的代码
使用openresty开发的在nginx层面拦截验证发送短信请求有效性的代码
\ No newline at end of file
\ No newline at end of file
mp-downloader/static/js/index.js
View file @
bc76441e
...
@@ -14,13 +14,13 @@ setInterval(function () {
...
@@ -14,13 +14,13 @@ setInterval(function () {
init
();
init
();
}
}
urlCircle
.
push
(
currentUrl
)
urlCircle
.
push
(
currentUrl
)
bindChangeImg
();
},
1000
);
},
1000
);
var
body
=
$
(
"#__nuxt"
);
var
body
=
$
(
"#__nuxt"
);
var
parentDom
=
$
(
document
.
createElement
(
"div"
));
var
parentDom
=
$
(
document
.
createElement
(
"div"
));
var
img
=
new
Image
();
var
img
=
new
Image
();
var
selectedList
=
[];
var
checkedProp
=
false
;
var
checkedProp
=
false
;
img
.
src
=
chrome
.
extension
.
getURL
(
"ui.html"
);
img
.
src
=
chrome
.
extension
.
getURL
(
"ui.html"
);
parentDom
.
addClass
(
"mpDonloaderParentDom"
);
parentDom
.
addClass
(
"mpDonloaderParentDom"
);
...
@@ -34,15 +34,14 @@ var isOpen = false;
...
@@ -34,15 +34,14 @@ var isOpen = false;
var
container
=
null
;
var
container
=
null
;
var
index
=
getIndex
();
var
index
=
getIndex
();
function
init
()
{
function
init
()
{
if
(
isOpen
)
{
if
(
isOpen
)
{
selectedList
=
[];
isOpen
=
false
;
isOpen
=
false
;
toggleButton
();
toggleButton
();
}
}
}
}
bindChangeImg
();
bindChangeImg
();
bindChangeWorkEvents
();
bindChangeWorkEvents
();
...
@@ -133,7 +132,9 @@ function setSelect(dom, all) {
...
@@ -133,7 +132,9 @@ function setSelect(dom, all) {
}
}
function
getImages
()
{
function
getImages
()
{
var
id
=
""
;
var
worksId
;
var
userNickname
;
var
userId
=
""
;
var
lists
=
[];
var
lists
=
[];
var
images
=
[];
var
images
=
[];
var
reg
=
/
\/\d{1,}\/
/g
;
var
reg
=
/
\/\d{1,}\/
/g
;
...
@@ -141,20 +142,28 @@ function getImages() {
...
@@ -141,20 +142,28 @@ function getImages() {
lists
=
$
(
".swiper-wrapper"
).
find
(
"img"
);
lists
=
$
(
".swiper-wrapper"
).
find
(
"img"
);
var
urls
=
[];
var
urls
=
[];
var
imgSrc
=
""
;
var
imgSrc
=
""
;
var
worksString
=
window
.
location
.
href
.
match
(
/
\w
orks
\/\S
*
\?
/g
);
if
(
worksString
.
length
>
0
)
{
worksId
=
worksString
[
0
].
replace
(
"works/"
,
""
);
worksId
=
worksId
.
replace
(
"?"
,
""
);
worksId
=
base64Decode
(
worksId
);
}
userNickname
=
$
(
$
(
".user-info > span.nickname"
)[
0
]).
text
();
$
.
each
(
lists
,
(
i
,
n
)
=>
{
$
.
each
(
lists
,
(
i
,
n
)
=>
{
urls
=
n
.
currentSrc
.
split
(
"!"
);
urls
=
n
.
currentSrc
.
split
(
"!"
);
imgSrc
=
urls
[
0
];
imgSrc
=
urls
[
0
];
if
(
imgSrc
.
indexOf
(
"videos.mepai.me"
)
<
0
)
{
if
(
imgSrc
.
indexOf
(
"videos.mepai.me"
)
<
0
)
{
if
(
records
.
indexOf
(
imgSrc
)
<
0
)
{
if
(
records
.
indexOf
(
imgSrc
)
<
0
)
{
if
(
i
d
===
""
)
{
if
(
userI
d
===
""
)
{
var
idStrings
=
imgSrc
.
match
(
reg
);
var
idStrings
=
imgSrc
.
match
(
reg
);
if
(
idStrings
.
length
>
0
)
{
if
(
idStrings
!==
undefined
&&
idStrings
.
length
>
0
)
{
i
d
=
idStrings
[
0
].
replace
(
/
\/
/g
,
""
);
userI
d
=
idStrings
[
0
].
replace
(
/
\/
/g
,
""
);
}
}
}
}
records
.
push
(
imgSrc
);
records
.
push
(
imgSrc
);
images
.
push
({
images
.
push
({
name
:
i
d
+
"-"
+
index
(),
name
:
worksId
+
"-"
+
userNickname
+
'-'
+
userI
d
+
"-"
+
index
(),
url
:
imgSrc
url
:
imgSrc
});
});
}
}
...
@@ -164,6 +173,13 @@ function getImages() {
...
@@ -164,6 +173,13 @@ function getImages() {
return
images
;
return
images
;
}
}
function
base64Decode
(
input
){
rv
=
window
.
atob
(
input
);
rv
=
escape
(
rv
);
rv
=
decodeURIComponent
(
rv
);
return
rv
;
}
function
selectAll
()
{
function
selectAll
()
{
checkedProp
=
!
checkedProp
;
checkedProp
=
!
checkedProp
;
$
(
$
(
body
).
find
(
"input[type='checkbox']"
)).
attr
(
"checked"
,
checkedProp
);
$
(
$
(
body
).
find
(
"input[type='checkbox']"
)).
attr
(
"checked"
,
checkedProp
);
...
@@ -198,8 +214,13 @@ function changeFocus() {
...
@@ -198,8 +214,13 @@ function changeFocus() {
}
}
function
downloadAll
()
{
function
downloadAll
()
{
if
(
confirm
(
"点击确定开始下载!"
))
{
if
(
confirm
(
"点击确定开始下载!"
))
{
var
q
=
$
(
"select[name=quality]"
).
val
();
var
ext
=
""
;
if
(
q
==
720
)
{
ext
=
"!720w.jpg"
;
}
$
.
each
(
$
(
body
).
find
(
"input[type='checkbox']:checked"
),
(
i
,
n
)
=>
{
$
.
each
(
$
(
body
).
find
(
"input[type='checkbox']:checked"
),
(
i
,
n
)
=>
{
downloadResource
(
$
(
n
).
val
()
,
$
(
n
).
attr
(
"fileid"
)
);
downloadResource
(
$
(
n
).
val
()
+
ext
,
$
(
n
).
attr
(
"fileid"
)
+
"-"
+
q
);
});
});
}
}
}
}
...
...
mp-downloader/ui.html
View file @
bc76441e
...
@@ -12,12 +12,26 @@
...
@@ -12,12 +12,26 @@
</div>
</div>
<div
class=
"images"
>
<div
class=
"images"
>
</div>
</div>
<div
class=
"buttons"
style=
""
>
<div
class=
"buttons"
style=
"height: 30px;display: flex"
>
<div
class=
"button selectAll"
>
<div
style=
"display: flex;margin-right:20px;"
>
<div>
画质:
</div>
<div
style=
"width: 120px"
>
<select
name=
"quality"
style=
"width: 120px;height:30px;background-color:
#ffeeb8;font-size: 16px;border: 1px #ded748 solid"
>
<option
value=
"720"
>
720P
</option>
<option
value=
"raw"
>
原图
</option>
</select>
</div>
</div>
<div>
<button
class=
"button selectAll"
style=
"height: 30px"
>
全选
全选
</button>
</div>
</div>
<div
class=
"button startDownload"
>
<div>
<button
class=
"button startDownload"
style=
"height: 30px"
>
下载
下载
</button>
</div>
</div>
</div>
</div>
</div>
</div>
nginx-ext/docker-compose.yaml
100644 → 100755
View file @
bc76441e
version
:
"
3"
version
:
"
3"
services
:
services
:
nginx
:
nginx
:
image
:
nginx:1.18.0
image
:
openresty/openresty
container_name
:
openresty
ports
:
ports
:
-
80:80
-
80:80
volumes
:
volumes
:
-
./test.conf:/
etc/nginx
/nginx.conf
-
./test.conf:/
usr/local/openresty/nginx/conf
/nginx.conf
nginx-ext/filter.conf
deleted
100644 → 0
View file @
fcf1d19f
content_by_lua_block
{
if
ngx
.
req
.
get_method
() ==
ngx
.
HTTP_GET
then
local
uri
=
ngx
.
var
.
uri
;
local
params
=
ngx
.
req
.
get_uri_args
();
ngx
.
log
(
ngx
.
ERR
,
"进入逻辑"
)
local
headers
=
ngx
.
req
.
get_headers
();
local
version
=
headers
[
"app-version"
];
local
device
=
headers
[
"app-device"
];
ngx
.
log
(
ngx
.
ERR
,
"device:"
..
device
)
if
version
==
nil
or
device
==
nil
then
ngx
.
exit
(
ngx
.
HTTP_UNAUTHORIZED
);
end
device
=
string
.
lower
(
device
);
local
sign
=
params
[
"sign"
];
local
t
=
params
[
"t"
];
if
device
==
"android"
or
device
==
"ios"
then
local
encodedSign
=
ngx
.
md5
(
device
..
t
..
version
);
if
encodedSign
~=
sign
then
ngx
.
log
(
ngx
.
ERR
,
"luaMd5的结果"
..
encodedSign
)
ngx
.
log
(
ngx
.
ERR
,
"客户端的sign:"
..
sign
)
ngx
.
exit
(
ngx
.
HTTP_UNAUTHORIZED
);
end
end
if
device
==
"www"
or
device
==
"m"
then
local
apiSecretId
=
"AKIDoN4nLkxNQcR5YttVjmdT7czC4f8PgeVG"
local
apiSecretKey
=
"mE6oLySlIfsysaI5pNuGRZWOXbUFqFkQ"
local
appId
=
"2030055684"
local
secretKey
=
"03sufjIZDGoItxXBvnx_4Ag"
local
ticket
=
params
[
"ticket"
];
local
randomStr
=
params
[
"randomStr"
];
local
ip
=
ngx
.
var
.
remote_addr
;
local
data
= {
"Action=DescribeCaptchaResult"
,
"AppSecretKey="
..
secretKey
,
"CaptchaAppId="
..
appId
,
"CaptchaType=9"
,
"Nonce="
..
random
(
1000
,
9000
),
"Randstr="
..
randomStr
,
"SecretId="
..
apiSecretId
"Ticket="
..
ticket
,
"Timestamp="
..
ngx
.
time
(),
"UserIp="
..
ip
,
"Version=2019-07-22"
,
}
local
str
=
""
;
for
value
in
data
do
if
(
postData
~=
""
)
then
str
=
str
..
"&"
..
value
else
str
=
value
end
end
local
waitToEncoded
=
"GETcaptcha.tencentcloudapi.com/?"
..
str
;
local
encodeStr
=
ngx
.
encode_base64
(
ngx
.
hmac_sha1
(
apiSecretKey
,
waitToEncoded
));
data
[
"Signature"
] =
encodeStr
;
local
finalStr
=
""
;
for
value
in
data
do
if
finalStr
~=
""
then
finalStr
=
finalStr
..
"&"
..
value
else
finalStr
=
value
end
end
local
t
=
ngx
.
location
.
capture
(
"https://captcha.tencentcloudapi.com/?"
..
finalStr
)
ngx
.
log
(
ngx
.
ERR
,
"从腾讯出来的结果"
..
t
)
ngx
.
log
(
ngx
.
ERR
,
"客户端ticket:"
..
ticket
)
if
t
.
Response
.
CaptchaCode
~=
1
then
ngx
.
exit
(
ngx
.
HTTP_UNAUTHORIZED
);
end
end
end
}
\ No newline at end of file
nginx-ext/test.conf
100644 → 100755
View file @
bc76441e
events
{
worker_connections
1024
;
}
http
{
server
{
listen
80
;
location
/
_
code_ticket
{
proxy_pass
"https://captcha.tencentcloudapi.com/"
;
}
location
/ {
add_header
Access
-
Control
-
Allow
-
Origin
"*"
always
;
add_header
Access
-
Control
-
Allow
-
Methods
'*'
always
;
add_header
Access
-
Control
-
Allow
-
Headers
'Origin, X-Requested-With, Content-Type, request-type,Accept, Authorization, accesstoken, app-version, app-device'
always
;
add_header
"Access-Control-Expose-Headers"
'page,per-page,total-rows'
always
;
if
($
request_uri
~
"/v1/user/code*"
) {
rewrite_by_lua_block
{
if
ngx
.
req
.
get_method
() ==
"GET"
then
local
uri
=
ngx
.
var
.
uri
;
local
params
=
ngx
.
req
.
get_uri_args
();
local
headers
=
ngx
.
req
.
get_headers
();
local
version
=
headers
[
"app-version"
];
local
device
=
headers
[
"app-device"
];
if
version
==
nil
or
device
==
nil
then
ngx
.
say
(
'{"code":"100500","message":"发送失败","data":[]}'
);
return
ngx
.
exit
(
0
)
end
device
=
string
.
lower
(
device
);
if
(
params
[
'mobile'
] ==
nil
)
then
ngx
.
say
(
'{"code":"100500","message":"发送失败","data":[]}'
);
return
ngx
.
exit
(
0
)
end
local
mobile
=
params
[
'mobile'
];
if
device
==
"android"
or
device
==
"ios"
then
if
(
params
[
"sign"
] ==
nil
or
params
[
"t"
] ==
nil
)
then
ngx
.
say
(
'{"code":"100500","message":"发送失败","data":[]}'
);
return
ngx
.
exit
(
0
)
end
local
sign
=
params
[
"sign"
];
local
t
=
params
[
"t"
];
local
encodedSign
=
ngx
.
md5
(
device
..
t
..
version
);
if
encodedSign
~=
sign
then
ngx
.
say
(
'{"code":"100500","message":"发送失败","data":[]}'
);
return
ngx
.
exit
(
0
)
end
end
if
device
==
"www"
or
device
==
"m"
then
local
apiSecretId
=
"AKIDoN4nLkxNQcR5YttVjmdT7czC4f8PgeVG"
local
apiSecretKey
=
"mE6oLySlIfsysaI5pNuGRZWOXbUFqFkQ"
local
appId
=
"2030055684"
local
secretKey
=
"03sufjIZDGoItxXBvnx_4Ag"
if
(
params
[
"ticket"
] ==
nil
or
params
[
"randstr"
] ==
nil
)
then
ngx
.
say
(
'{"code":"100500","message":"发送失败","data":[]}'
);
return
ngx
.
exit
(
0
)
end
local
ticket
=
params
[
"ticket"
];
local
randomStr
=
params
[
"randstr"
];
local
ip
=
ngx
.
var
.
remote_addr
;
local
data
= {
[
"Action"
] =
"DescribeCaptchaResult"
,
[
"AppSecretKey"
] =
secretKey
,
[
"CaptchaAppId"
] =
appId
,
[
"CaptchaType"
] =
9
,
[
"Nonce"
] =
tostring
(
math
.
random
(
1000
,
9000
)),
[
"Randstr"
] =
randomStr
,
[
"SecretId"
] =
apiSecretId
,
[
"Ticket"
] =
ticket
,
[
"Timestamp"
] =
tostring
(
ngx
.
time
()),
[
"UserIp"
] =
ip
,
[
"Version"
] =
"2019-07-22"
,
}
local
str
=
""
;
local
tempTable
= {};
for
i
,
value
in
pairs
(
data
)
do
table
.
insert
(
tempTable
,
i
..
"="
..
value
)
end
local
waitToEncoded
=
"GETcaptcha.tencentcloudapi.com/?"
..
table
.
concat
(
tempTable
,
"&"
);
local
encodeStr
=
ngx
.
encode_base64
(
ngx
.
hmac_sha1
(
apiSecretKey
,
waitToEncoded
));
data
[
"Signature"
] =
encodeStr
;
local
txResult
=
ngx
.
location
.
capture
(
"/_code_ticket"
,
{
method
=
ngx
.
HTTP_GET
,
args
=
data
}
)
local
Response
=
string
.
lower
(
tostring
(
txResult
.
body
))
ngx
.
log
(
ngx
.
ERR
,
Response
);
if
string
.
find
(
Response
,
"ok"
) ==
nil
then
ngx
.
say
(
'{"code":"100500","message":"发送失败","data":[]}'
);
return
ngx
.
exit
(
0
)
end
end
end
}
}
}
}
}
}
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