filter-bot-background-cs
// ==UserScript==
// @name filter-bot-background-cs
// @namespace https://bbs.tampermonkey.net.cn/
// @version 1.7.5
// @description If the project could run successfully, although you don't know why and how, just let it go.🥺
// @author sloan
// @match https://t.bilibili.com/*
// @match https://space.bilibili.com/33605910*
// @match https://space.bilibili.com/1971267524*
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @require https://scriptcat.org/lib/532/1.0.2/ajax.js
// @connect gitee.com
// @connect bilibili.com
// @connect 79f5c7ff-f78b-4e84-ac29-3771fef4f2f6.bspapp.com
// @connect fc-mp-79f5c7ff-f78b-4e84-ac29-3771fef4f2f6.next.bspapp.com
// ==/UserScript==
(async function () {
'use strict';
var myDate = new Date()
var s_wlist, s_blist, keyword, csrf, ids, firstCount, reportType, awaitTime, sensitive, checkAll, pendantName, isOpen, isOne, urls, tagId
const topic_id = "36153"
if (GM_getValue('Month') != myDate.getMonth()) {
GM_deleteValue('trashCan')
GM_deleteValue("doneNew")
GM_deleteValue("allData")
GM_deleteValue("clearTag")
GM_setValue('Month', myDate.getMonth())
}
if (myDate.getTime() > GM_getValue('DateTime')) {
GM_deleteValue("allData")
GM_setValue('DateTime', myDate.setDate(myDate.getDate() + 2))
}
function getCookie() {
var obj = new RegExp(/(?<=_jct=).+?(?=; )/)
var cookie = document.cookie
csrf = cookie.match(obj)[0]
}
function sleep(time) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, time);
});
}
function random(arr = []) {
arr.sort(function () {
return Math.random() - 0.5
})
return arr
}
function getConfig() {
GM_xmlhttpRequest({
url: "https://79f5c7ff-f78b-4e84-ac29-3771fef4f2f6.bspapp.com/getMenu",
method: "GET",
onload: function (data) {
var json = JSON.parse(data.responseText);
GM_setValue('ids', json.ids ?? '33605910');
GM_setValue('firstCount', json.number ?? '250');
GM_setValue('reportType', json.reportType ?? [4]);
GM_setValue('awaitTime', json.awaitTime ?? 1);
GM_setValue('addKey', json.sensitive ?? '3');
GM_setValue('checkAll', json.checkAll ?? false);
GM_setValue('pendantName', json.pendantName ?? '');
GM_setValue('isOpen', json.isOpen ?? false);
GM_setValue('isOne', json.isOne ?? false);
GM_setValue('urls', json.urls ?? '');
GM_setValue('tagId', json.tagId ?? '');
}
});
// console.log(GM_getValue('ids'), 898798)
ids = GM_getValue('ids');
firstCount = GM_getValue('firstCount');
reportType = GM_getValue('reportType');
awaitTime = GM_getValue('awaitTime') || 1;
sensitive = GM_getValue('addKey') || '3'
checkAll = GM_getValue('checkAll') || false
pendantName = GM_getValue('pendantName') || ''
isOpen = GM_getValue('isOpen') || false
isOne = GM_getValue('isOne') ?? false
urls = GM_getValue('urls') ?? ''
tagId = GM_getValue('tagId') ?? '13332'
console.log(awaitTime, pendantName, 8555)
GM_xmlhttpRequest({
url: 'https://gitee.com/wind_du/links/raw/master/wlist.json',
method: "GET",
onload: function (data) {
var json = data.status != 403 ? JSON.parse(data.responseText): []
GM_setValue('zerolist', json ?? []);
}
});
var wlist = GM_getValue('zerolist');
s_wlist = new Set(wlist);
//
GM_xmlhttpRequest({
url: 'https://gitee.com/wind_du/links/raw/master/blist.json',
method: "GET",
onload: function (data) {
var json = data.status != 403 ? JSON.parse(data.responseText) : []
GM_setValue('onelist', json ?? []);
}
});
var blist = GM_getValue('onelist');
s_blist = new Set(blist);
//
GM_xmlhttpRequest({
url: 'https://gitee.com/wind_du/links/raw/master/sensitive.txt',
method: "GET",
onload: function (data) {
var text = data.status != 403 ? data.responseText: ''
GM_setValue('sensitive', text ?? "");
}
});
console.log('test')
keyword = new RegExp("锟斤拷|" + unescape(GM_getValue('sensitive')) + '|' + sensitive)
}
//
getConfig()
await sleep(2000)
getCookie()
// getMessage()
setInterval(function () { Gopatrol() }, 10000)
setInterval(function () { location.reload() }, 1800000)
var url = window.location.href
var reg1 = new RegExp("https://t.bilibili.com/[0-9].*")
let tagList = await getTagList()
if (tagList.length) {
const clearList = await clearCheck(tagList)
for (let x of clearList) {
clearTag(x, csrf)
await sleep(100 + Math.floor(Math.random() * 10))
}
}
if (reg1.test(url)) {
act()
} else if (isOne && urls) {
await sleep(1000)
let data = await getUrl()
//console.log(data, '0123')
if (!data.item) return
const oneType = data.item.basic.comment_type
const oneIds = data.item.basic.comment_id_str
await sleep(5000)
let handleOne = async () => {
let result = await GOreport(oneType, oneIds)
if (result) {
console.log("已全部处理完毕,10分钟后将刷新网页")
await sleep(600000)
location.reload()
}
}
handleOne()
}
else {
GoAll()
}
function getMessage() {
ajax(`https://message.bilibili.com/x/sys-msg/update_cursor`, {
method: 'get',
_nocatch: true
})
}
function getTagList() {
let sort_by = [1, 2, 3]
let sortNum = sort_by[Math.floor(Math.random() * sort_by.length)]
tagId = tagId || 13332
// console.log(tagId, 'ttttt')
return new Promise(resolve => {
GM_xmlhttpRequest({
url: `https://app.bilibili.com/x/topic/web/details/cards?topic_id=${tagId}&sort_by=${sortNum}&offset=&page_size=20&source=Web`,
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
onload: function (data) {
var json = JSON.parse(data.responseText)
if (json.data.topic_card_list.items) {
var items = json.data.topic_card_list.items
resolve(items)
} else {
resolve([])
}
}
})
})
}
function clearCheck(items) {
return new Promise(resolve => {
var aimlist = []
for (let x of items) {
var id_str = x.dynamic_card_item.id_str
aimlist.push(id_str)
}
resolve(aimlist)
})
}
function clearTag(id_str, csrf) {
if (typeof id_str != typeof "hello") {
id_str = String(id_str)
}
GM_xmlhttpRequest({
url: "https://app.bilibili.com/x/topic/resource/report",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: 'topic_id=' + tagId + '&res_type=0&res_id_str=' + id_str + `&reason=与话题无关&csrf=` + csrf,
onload: function (resp) {
var json = JSON.parse(resp.responseText)
if (json.code == 0) {
let tags = ['虚假不实信息', '引战', '垃圾广告', '色情']
let reason = tags[Math.floor(Math.random() * tags.length)]
GM_xmlhttpRequest({
url: "https://app.bilibili.com/x/topic/resource/report",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: 'topic_id=' + tagId + '&res_type=0&res_id_str=' + id_str + `&reason=${reason}&csrf=` + csrf,
onload: function (resp) {
let back = JSON.parse(resp.responseText)
if (back.code == 0) {
console.log("清理成功√")
}
else {
console.log("不明原因失败")
}
}
})
}
else {
console.log("不明原因失败")
}
}
})
}
async function getUrl() {
// oneIds && oneType
let list = urls.split('?')[0].match(/[0-9]{4,30}/g)
return new Promise(resolve => {
GM_xmlhttpRequest({
url: `https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id=${list[0]}`,
method: "GET",
headers: {
"Referer": urls,
"Content-Type": "application/x-www-form-urlencoded",
},
onload: function (resp) {
try {
let json = JSON.parse(resp.responseText)
resolve(json.data)
}
catch {
console.log("请求过于频繁")
resolve()
}
}
})
})
}
async function saveData(list) {
const json = await ajax(`https://fc-mp-79f5c7ff-f78b-4e84-ac29-3771fef4f2f6.next.bspapp.com/csMessage`, {
method: 'post',
data: { list: list, type: 'newAdd' },
responseType: 'json',
_nocatch: true
})
}
async function act() {
await sleep(5000)
/*try {
var type, oid
var url = window.location.href
var obj = new RegExp(/(?<=com\/).+?(?=\?)/)
var id = url.match(obj)
GM_xmlhttpRequest({
url: `https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id=${id}`,
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
onload: async function (resp) {
var json = JSON.parse(resp.responseText)
type = json.data.item.basic.comment_type
oid = json.data.item.basic.comment_id_str
let result = await GOreport(type, oid)
if (result) {
console.log("已全部处理完毕,10分钟后将刷新网页")
await sleep(600000)
location.reload()
}
}
})
}*/
// catch {
try {
var text = document.querySelector(".list-item").getAttribute("mr-show")
var json = JSON.parse(text)
var type = json.msg.type
var oid = json.msg.oid
let anoy = async () => {
let result = await GOreport(type, oid)
if (result) {
console.log("已全部处理完毕,10分钟后将刷新网页")
await sleep(600000)
location.reload()
}
}
anoy()
}
catch {
console.log("评论板块加载失败")
}
// }
}
function GoAll() {
function getall(host_mid, offset) {
return new Promise(resolve => {
GM_xmlhttpRequest({
url: `http://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?offset=${offset}&host_mid=${host_mid}`,
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
onload: function (resp) {
try {
let json = JSON.parse(resp.responseText)
resolve(json.data)
}
catch {
console.log("请求过于频繁")
resolve()
}
}
})
})
}
// 动态
async function handleAll(id_str) {
let reportTypes = [1, 5, 9, 7, 8, 12]
return new Promise(async resolve => {
const data = await ajax(`https://api.bilibili.com/x/dynamic/feed/dynamic_report/add?csrf=${csrf}`, {
method: 'post',
data: {
accused_uid: Number(ids),
dynamic_id: id_str,
reason_type: reportTypes[Math.floor(Math.random() * reportTypes.length)],
reason_desc: null
},
responseType: 'json',
_nocatch: true
})
resolve(id_str)
// console.log(data, 'test')
})
}
function getAidData(aid) {
return new Promise(resolve => {
GM_xmlhttpRequest({
url: `https://api.bilibili.com/x/tag/archive/tags?aid=${aid}`,
method: "GET",
onload: function (data) {
var json = JSON.parse(data.responseText)
var items = json.data
console.log(items, 'itemst')
resolve(items || [])
}
})
})
}
// 校验数组还是对象
function checkType(obj) {
var type = Object.prototype.toString.call(obj)
if (type == "[object Array]") {
return true
} else {
return false
}
}
function clearAidTag(list, aid) {
let clearTag = GM_getValue('clearTag') || {}
clearTag = checkType(clearTag) ? {} : clearTag
console.log(clearTag, 'clearTag')
const newList = list.filter(item => !(clearTag.aid && clearTag[aid].some(it => it == item.tag_id)))
// console.log(newList, clearTag, 'qqqweqwe')
return new Promise(async resolve => {
for (let i = 0; i < newList.length; i++) {
const element = newList[i].tag_id;
GM_xmlhttpRequest({
url: "https://api.bilibili.com/x/tag/archive/hate2",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: 'aid=' + aid + `&tag_id=${element}` + '&csrf=' + csrf,
onload: function (resp) {
let back = JSON.parse(resp.responseText)
if (back.code == 0 || back.code == 16107) {
clearTag[aid] = clearTag[aid] || []
clearTag[aid].push(element)
GM_setValue('clearTag', clearTag ?? {});
console.log(clearTag)
}
console.log(back, 'tttwwwq')
}
})
await sleep(300 + Math.floor(Math.random() * 500))
}
resolve()
})
}
// clearTag
async function clearTagss(items) {
return new Promise(async resolve => {
let aidList = []
for (const key in items) {
const major = items[key].modules && items[key].modules.module_dynamic.major
if (major && major.type === 'MAJOR_TYPE_ARCHIVE') {
aidList.push(major.archive.aid)
}
}
for (let i = 0; i < aidList.length; i++) {
const List = await getAidData(aidList[i])
await sleep(300 + Math.floor(Math.random() * 500))
await clearAidTag(List, aidList[i])
}
resolve()
})
}
async function main() {
let has_more = true
let offset = ""
let items = []
console.log(ids, "正在获取所有动态")
let keyId = ids || 33605910
while (has_more) {
let lst = await getall(keyId, offset)
has_more = lst.has_more
has_more = has_more && (firstCount < items.length ? false : true)
offset = lst.offset
items.push.apply(items, lst.items)
await sleep(2 + Math.floor(Math.random() * 10))
}
items = items.slice(0, firstCount)
//let lst1 = await getall(1971267524, "")
//items.push.apply(items, lst1.items)
items = items.filter(it => it.id_str != 662016827293958168)
console.log(`总计${items.length}条动态`, items)
let typepart = []
let oidpart = []
for (let i = 0; i < items.length; i++) {
typepart.push(items[i].basic.comment_type)
oidpart.push(items[i].basic.comment_id_str)
}
let obj = {}
obj[ids] = []
const newDoneObj = GM_getValue("doneNew", obj)
newDoneObj[ids] = newDoneObj[ids] ?? []
console.log("已完成扫描" + newDoneObj[ids].length + "/" + oidpart.length)
const allData = GM_getValue("allData", []) || []
//console.log(allData, 'tsq')
while (newDoneObj[ids].length < oidpart.length || oidpart.some(it => !newDoneObj[ids].some(val => val == it))) {
let xr = Math.floor(Math.random() * (oidpart.length))
await clearTagss([items[xr]])
if (checkAll && !allData.some(it => it == oidpart[xr])) {
const aList = await handleAll(oidpart[xr])
allData.push(aList)
GM_setValue("allData", allData)
}
var doneOid = newDoneObj
let hasList = doneOid[ids]
if (hasList.some(it => it == oidpart[xr])) {
console.log("该动态已处理过")
continue
}
else {
let result = await GOreport(typepart[xr], oidpart[xr])
if (result) {
console.log("已处理完一个动态")
let linb = Array.from(hasList.push(oidpart[xr]))
newDoneObj.ids = linb
GM_setValue("doneNew", newDoneObj)
}
}
}
}
main()
}
//
function Gopatrol() {
function getDetails() {
return new Promise(resolve => {
GM_xmlhttpRequest({
url: `https://app.bilibili.com/x/topic/web/details/cards?topic_id=${topic_id}&sort_by=3&offset=&page_size=100&source=Web`,
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
onload: function (data) {
var json = JSON.parse(data.responseText)
var items = json.data.topic_card_list.items
resolve(items)
}
})
})
}
function check(items) {
return new Promise(resolve => {
var aimlist = []
for (let x of items) {
var id_str = x.dynamic_card_item.id_str
var mid = x.dynamic_card_item.modules.module_author.mid
var username = x.dynamic_card_item.modules.module_author.name
try { var text = x.dynamic_card_item.modules.module_dynamic.desc.text }
catch { text = "wronggggggggggggggg" }
if (s_blist.has(mid) && !s_wlist.has(mid) || username.match(keyword) || text.match(keyword)) {
aimlist.push(id_str)
}
}
resolve(aimlist)
})
}
function report(id_str, csrf) {
if (typeof id_str != typeof "hello") {
id_str = String(id_str)
}
GM_xmlhttpRequest({
url: "https://app.bilibili.com/x/topic/resource/report",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: 'topic_id=' + topic_id + '&res_type=0&res_id_str=' + id_str + '&reason=话题不相关&csrf=' + csrf,
onload: function (resp) {
var json = JSON.parse(resp.responseText)
if (json.code == 0) {
GM_xmlhttpRequest({
url: "https://app.bilibili.com/x/topic/resource/report",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: 'topic_id=' + topic_id + '&res_type=0&res_id_str=' + id_str + '&reason=引战&csrf=' + csrf,
onload: function (resp) {
let back = JSON.parse(resp.responseText)
if (back.code == 0) {
console.log("清理成功√")
}
else {
console.log("不明原因失败")
}
}
})
}
else {
console.log("不明原因失败")
}
}
})
}
async function main() {
try { getCookie() }
catch { return }
await sleep(50)
var items = await getDetails()
var aimlist = await check(items)
for (let x of aimlist) {
report(x, csrf)
await sleep(50 + Math.floor(Math.random() * 10))
}
await sleep(2000)
if (aimlist.length == 0 && items.length != 0) {
return
}
else {
console.log(`已图图${aimlist.length}个不明动态`)
}
aimlist = []
}
main()
}
async function GOreport(type, oid) {
return new Promise(resolve => {
var selec = reportType || [4]
// [4, 7, 3, 1]
function getRpl(type, oid, sort, pn) { //获取默认49个主楼评论
return new Promise(resolve => {
GM_xmlhttpRequest({
url: `https://api.bilibili.com/x/v2/reply?type=${type}&oid=${oid}&sort=${sort}&pn=${pn}&ps=49`,
method: "GET",
anonymous: true,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
onload: async function (resp) {
var json = JSON.parse(resp.responseText)
// console.log(json,'010101')
if (json.code == 0) {
resolve(json.data.replies)
}
else {
console.log("请求频繁,请更换ip或休息一段时间再尝试,建议“动态”与“空间”页面只开其中一个,fbot与fbot-background只开其中一个")
console.log("10分钟后将重新加载网页")
await sleep(600000)
location.reload()
}
}
})
}
)
}
function check(replies) {//筛选出操作对象
return new Promise(resolve => {
var obj = {
aimlist: [],
rpids: []
}
for (let x of replies) {
var rpid_str = x.rpid_str
var mid = x.mid
var uname = x.member.uname
var message = x.content.message
var reply = x.replies
var pName = x.member.pendant.name
if (!isOpen && (s_blist.has(mid) && !s_wlist.has(mid) || uname.match(keyword) || message.match(keyword))) {
obj.aimlist.push(rpid_str)
} else if (checkAll && !s_wlist.has(mid)) {
obj.aimlist.push(rpid_str)
}
if (pName.match(pendantName) && !s_wlist.has(mid)) {
obj.aimlist.push(rpid_str)
}
if (!isOpen && reply != null) {
obj.rpids.push(x.rpid)
}
}
resolve(obj)
})
}
function checkhate(replies) {
return new Promise(resolve => {
var hatelist = []
for (let x of replies) {
var rpid_str = x.rpid_str
var mid = x.mid
var uname = x.member.uname
var message = x.content.message
var action = x.action
var pName = x.member.pendant.name
if (!isOpen && (s_blist.has(mid) && !s_wlist.has(mid) || uname.match(keyword) || message.match(keyword))) {
if (action != 2) {
hatelist.push(rpid_str)
}
} else if (checkAll && !s_wlist.has(mid)) {
hatelist.push(rpid_str)
}
if (pName.match(pendantName) && !s_wlist.has(mid)) {
hatelist.push(rpid_str)
}
}
resolve(hatelist)
})
}
function recordData(replies) {
var recordList = []
for (let x of replies) {
var mid = x.mid
var uname = x.member.uname
var message = x.content.message
if (s_blist.has(mid) && !s_wlist.has(mid) || uname.match(keyword) || message.match(keyword)) {
let mid = x.mid
x.wlist = s_wlist.has(mid)
x.blist = s_blist.has(mid)
recordList.push(x)
}
}
recordList.length && saveData(recordList)
}
function action(type, oid, rpid_str, csrf) {
return new Promise(resolve => {
GM_xmlhttpRequest({
url: "https://api.bilibili.com/x/v2/reply/report",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: `oid=${oid}&type=${type}&rpid=${rpid_str}&reason=${selec[Math.floor(Math.random() * reportType.length)]}&csrf=${csrf}`,
onload: function (resp) {
var json = JSON.parse(resp.responseText)
// console.log(json)
if (json.code == 0 || json.code == 12008 || json.code == 12006) {
GM_setValue('trashCan', GM_getValue('trashCan') + '|' + rpid_str)
console.log("success")
let status = json.code == 0 ? 1 : 2
resolve(status)
}
else {
console.log(json)
resolve(false)
}
}
})
})
}
function hate(type, oid, rpid_str, csrf) {
GM_xmlhttpRequest({
url: 'https://api.bilibili.com/x/v2/reply/hate',
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: `oid=${oid}&type=${type}&rpid=${rpid_str}&action=1&ordering=time&jsonp=jsonp&csrf=${csrf}`,
onload: function (resp) {
var json = JSON.parse(resp.responseText)
if (json.code == 0) {
return
}
else {
console.log("点踩失败", json)
}
}
})
}
async function main() {
var replies = []
console.log("开始获取所有主楼评论")
try {
for (var i = 1; i <= 200; i++) { //调试时取i<=1,正常使用为i<=999
var linb = await getRpl(type, oid, 0, i)
await sleep(20 + Math.floor(Math.random() * 10))
if (linb == null) {
break
}
if (linb.length == 0) {
break
}
replies.push.apply(replies, linb)
console.log("获取中……")
}
}
catch {
console.log("获取评论有缺失")
}
console.log("主楼评论获取成功", replies)
var robj = await check(replies)
var aimlist = robj.aimlist
var hatelist = await checkhate(replies)
recordData(replies)
aimlist = random(aimlist)
hatelist = random(hatelist)
console.log("需要处理的如下")
console.log(aimlist)
var aims = []
var affirm = false
var morerply = []
let more = async () => {
for (let x of robj.rpids) {
for (let i = 1; i < 100; i++) {
let lins = await ajax(`https://api.bilibili.com/x/v2/reply/reply?type=${type}&oid=${oid}&root=${x}&pn=${i}`, {
method: "GET",
anonymous: true,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
responseType: 'json',
_nocatch: true
})
if (lins == null) {
break
}
else if (lins.data && lins.data.replies == null) {
break
}
else if (lins.data.replies && lins.data.replies.length < 20) {
morerply.push.apply(morerply, lins.data.replies)
break
}
else {
morerply.push.apply(morerply, lins.data.replies)
await sleep(200)
}
}
}
console.log("楼中楼评论获取成功", morerply)
let ha = await checkhate(morerply)
recordData(morerply)
ha = random(ha)
affirm = true
let hatess = async () => {
for (let x of ha) {
hate(type, oid, x, csrf)
await sleep(5000 + Math.floor(Math.random() * 1000))
}
}
hatess()
}
var hating = async () => {
for (let x of hatelist) {
hate(type, oid, x, csrf)
await sleep(5000 + Math.floor(Math.random() * 1000))
}
}
hating()
more()
var cnt = 0
while (aimlist.length != 0) {
cnt++
var reg = new RegExp(GM_getValue('trashCan', '14514'))
for (let x of aimlist) {
if (x.match(reg)) {
console.log("之前已处理过")
aimlist = aimlist.filter(item => item != x)
continue
}
var isTrue = await action(type, oid, x, csrf)
if (isTrue) {
aimlist = aimlist.filter(item => item != x)
}
if (isTrue == 1 || !isTrue) {
await sleep(60000 * awaitTime + Math.floor(Math.random() * 10000))
} else {
await sleep(Math.floor(Math.random() * 10000))
}
}
if (aimlist.length != 0) {
console.log(`第${cnt}轮处理完毕,本轮剩余待处理项${aimlist.length}个`)
}
if (aimlist.length == 0) {
console.log("主楼评论处理完毕")
}
}
if (aimlist.length == 0) {
var cl
cl = setInterval(async function () {
if (affirm) {
console.log("开始处理楼中楼评论")
clearInterval(cl)
let aobj = await check(morerply)
aims = aobj.aimlist
aims = random(aims)
console.log("需要处理的楼中楼评论", aims)
if (aims == undefined) {
console.log("hear")
resolve(true)
}
var cnt = 0
while (aims.length != 0) {
cnt++
var reg = new RegExp(GM_getValue('trashCan', '14514'))
for (let x of aims) {
if (x.match(reg)) {
console.log("之前已处理过")
aims = aims.filter(item => item != x)
continue
}
var isTrue = await action(type, oid, x, csrf)
if (isTrue) {
aims = aims.filter(item => item != x)
}
if (isTrue == 1 || !isTrue) {
await sleep(60000 * awaitTime + Math.floor(Math.random() * 10000))
} else {
await sleep(Math.floor(Math.random() * 10000))
}
}
if (aims.length != 0) {
console.log(`第${cnt}轮处理完毕,本轮剩余待处理项${aims.length}个`)
}
}
if (aims.length == 0) {
resolve(true)
}
}
}, 6000)
}
}
main()
})
}
})();