// ==UserScript== // @name 青年大学习 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.0 // @description try to take over the world! // @author tfsn20 // @crontab * 1-23 once * * // @grant GM_getValue // @grant GM_xmlhttpRequest // @grant GM_log // ==/UserScript== /* ==UserConfig== 必填: cookie: title: cookie description: 其实只要cookie的stw即可 --- 建议填: token: title: token description: 可有可无, 填上以防万一 UA: title: UA description: 可有可无, 填上以防万一 ==/UserConfig== */ let anonymous = true; let cookie = GM_getValue('必填.cookie'), token = GM_getValue('建议填.token'), UA = GM_getValue('建议填.UA'); function getList() { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ url: `http://hnqndaxuexi.dahejs.cn/stw/news/list?&pageNumber=1&pageSize=10`, method: 'GET', data: ``, anonymous: anonymous, headers: { 'sec-ch-ua-platform': '', 'dnt': '', 'sec-ch-ua': '', 'sec-ch-ua-mobile': '', 'Sec-Fetch-Site': '', 'Sec-Fetch-Mode': '', 'Sec-Fetch-Dest': '', 'Host': 'hnqndaxuexi.dahejs.cn', 'Connection': 'keep-alive', 'accept': '*/*', 'User-Agent': UA, 'Content-Type': 'application/json', 'X-Requested-With': 'com.tencent.mm', 'Referer': 'http://hnqndaxuexi.dahejs.cn/study/studyList', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'Cookie': cookie, }, onload: function (xhr) { let json = JSON.parse(xhr.response) GM_log({ result: json }); resolve(json) } }) }) } function studyByID(id) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ url: `http://hnqndaxuexi.dahejs.cn/stw/news/study/${id}`, method: 'POST', data: ``, anonymous: anonymous, headers: { 'sec-ch-ua-platform': '', 'dnt': '', 'sec-ch-ua': '', 'sec-ch-ua-mobile': '', 'Sec-Fetch-Site': '', 'Sec-Fetch-Mode': '', 'Sec-Fetch-Dest': '', 'Host': 'hnqndaxuexi.dahejs.cn', 'Connection': 'keep-alive', 'accept': '*/*', 'User-Agent': UA, 'token': token, 'Content-Type': 'application/x-www-form-urlencoded', 'Origin': 'http://hnqndaxuexi.dahejs.cn', 'X-Requested-With': 'com.tencent.mm', 'Referer': 'http://hnqndaxuexi.dahejs.cn/study/gohome', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'Cookie': cookie, }, onload: function (xhr) { let json = JSON.parse(xhr.response) GM_log({ result: json }); resolve(json) } }) }) } return new Promise(async (resolve, reject) => { // Your code here... let latestID = (await getList()).obj.news.list[0].id; await studyByID(latestID); resolve(); });