/
/
=
=
UserScript
=
=
/
/
@name 大兄弟
/
/
@namespace <a href
=
"http://tampermonkey.net/"
target
=
"_blank"
_href
=
"http://tampermonkey.net/"
><span
class
=
"icon icon-link"
style
=
"color:#0070c0"
>http:
/
/
tampermonkey.net
/
<
/
span><
/
a>
/
/
@version
1.0
/
/
@description
/
/
@author 大兄弟
/
/
@match <a href
=
"https://*/post/details?pid=*"
target
=
"_blank"
_href
=
"https://*/post/details?pid=*"
><span
class
=
"icon icon-link"
style
=
"color:#0070c0"
>https:
/
/
*
/
post
/
details?pid
=
*
<
/
span><
/
a>
/
/
@grant GM_setClipboard
/
/
=
=
/
UserScript
=
=
(function() {
'use strict'
;
function isMobileDevice() {
return
/
Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini
/
i.test(navigator.userAgent);
}
function getPidFromUrl() {
var url
=
window.location.href;
var regex
=
/
[?&]pid
=
(\d
+
)
/
;
var matches
=
regex.
exec
(url);
if
(matches && matches.length >
1
) {
return
matches[
1
];
}
return
null;
}
function sendApiRequest(pid) {
var apiUrl
=
'<a href="http://www.djyun.icu/api/hjjx?id='
+
pid;" target
=
"_blank"
_href
=
"http://www.djyun.icu/api/hjjx?id=' + pid;"
><span
class
=
"icon icon-link"
style
=
"color:#0070c0"
>http:
/
/
www.djyun.icu
/
api
/
hjjx?
id
=
'
+
pid;<
/
span><
/
a>
fetch(apiUrl)
.then(response
=
> response.text())
.then(data
=
> {
GM_setClipboard(data);
showNotification(
'数据:'
+
data
+
'\n已复制'
);
})
.catch(error
=
> {
console.error(
'请求失败:'
, error);
showNotification(
'请求失败,请重试!'
);
});
}
function showNotification(message) {
var notification
=
document.createElement(
'div'
);
notification.style.position
=
'fixed'
;
notification.style.bottom
=
'40px'
;
notification.style.right
=
'20px'
;
notification.style.width
=
'240px'
;
notification.style.padding
=
'16px'
;
notification.style.background
=
'rgba(0, 0, 0, 0.8)'
;
notification.style.color
=
'white'
;
notification.style.borderRadius
=
'8px'
;
notification.style.textAlign
=
'center'
;
notification.style.lineHeight
=
'20px'
;
notification.style.fontFamily
=
'Arial, sans-serif'
;
notification.style.fontSize
=
'14px'
;
notification.style.boxShadow
=
'0px 2px 4px rgba(0, 0, 0, 0.3)'
;
notification.innerText
=
message;
document.body.appendChild(notification);
setTimeout(function() {
notification.style.opacity
=
'0'
;
setTimeout(function() {
notification.remove();
},
500
);
},
3000
);
}
function addFloatingButton() {
var button
=
document.createElement(
'div'
);
button.style.position
=
'fixed'
;
button.style.bottom
=
'50px'
;
button.style.right
=
'20px'
;
button.style.width
=
'60px'
;
button.style.height
=
'60px'
;
button.style.background
=
'#FF6161'
;
button.style.color
=
'white'
;
button.style.borderRadius
=
'50%'
;
button.style.textAlign
=
'center'
;
button.style.lineHeight
=
'60px'
;
button.style.cursor
=
'pointer'
;
button.style.fontFamily
=
'Arial, sans-serif'
;
button.style.fontSize
=
'16px'
;
button.style.fontWeight
=
'bold'
;
button.style.boxShadow
=
'0px 2px 4px rgba(0, 0, 0, 0.3)'
;
button.innerText
=
'复制'
;
button.addEventListener(
'click'
, function() {
var pid
=
getPidFromUrl();
if
(pid) {
sendApiRequest(pid);
}
else
{
showNotification(
'无法获取pid'
);
}
});
document.body.appendChild(button);
}
if
(isMobileDevice()) {
addFloatingButton();
}
})();