签到-666资源站
// ==UserScript==
// @name 签到-666资源站
// @namespace https://www.666php.com/
// @version 0.1.1
// @description try to take over the world!
// @author ccr
// @crontab * 10-23 once * *
// @connect www.666php.com
// @grant GM_notification
// @grant GM_xmlhttpRequest
// @grant GM_log
// @grant GM_cookie
// @grant GM_getValue
// @grant GM_listValues
// ==/UserScript==
return new Promise((resolve, reject) => {
// Your code here...
GM_xmlhttpRequest({
method: 'POST',
url: "https://www.666php.com/wp-admin/admin-ajax.php",
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'https://www.666php.com/'
},
data: `action=user_login&username=${GM_getValue("username")}&password=${GM_getValue("password")}`,
onload: function (xhr) {
var res = xhr.responseText;
var resObj = JSON.parse(res);
var msg = resObj.msg;
if (resObj.status == "1") {
GM_log(msg, "info")
} else {
GM_log(msg, "error")
}
resolve(xhr);
},
})
}).then(async (resXhr) => {
var resObjText = resXhr.responseText;
var resObj = JSON.parse(resObjText)
var headerArr = resXhr.responseHeaders.split('\r\n');
var headers = {};
headerArr.forEach(item => {
if (item !== '') {
var index = item.indexOf(':');
var key = item.slice(0, index);
var value = item.slice(index + 1).trim();
headers[key] = value
}
});
var setcookie = headers['set-cookie'];
var setcookieArray = setcookie.split('\n');
var setcookieTemp = '';
for (var i = 0; i < setcookieArray.length; i++) {
setcookieTemp = setcookieTemp + setcookieArray[i] + "; "
}
return await new Promise((resolve_1, reject_1) => {
if (resObj.status == "1") {
GM_xmlhttpRequest({
method: 'POST',
url: 'https://www.666php.com/wp-admin/admin-ajax.php',
data: 'action=user_qiandao',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'https://www.666php.com/',
'Cookie': setcookieTemp
},
onload: function (xhr_1) {
let msg = JSON.parse(xhr_1.responseText).msg;
GM_log(msg, "info")
GM_notification('666资源站签到成功:\n' + msg)
resolve_1()
},
})
} else {
resolve_1()
}
})
});
//获取指定名称的cookie的值
function getcookie(objname, setcookie) {
var arrstr = setcookie.split("; ");
for (var i = 0; i < arrstr.length; i++) {
var temp = arrstr[i].split("=");
if (temp[0] == objname) return unescape(temp[1]);
}
}