Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
『净网卫士』 吾爱破解论坛
// ==UserScript==
// @author Hunlongyu
// @name 『净网卫士』 吾爱破解论坛
// @namespace https://github.com/Hunlongyu
// @icon https://i.loli.net/2019/04/22/5cbd720718fdb.png
// @description 移除广告,精简页面。新增论坛后台自动签到。
// @version 0.3.3
// @include *://*.52pojie.cn/*
// @grant GM_addStyle
// @run-at document-start
// @updateURL https://gist.githubusercontent.com/Hunlongyu/5eef950d53b733dd67abda224ebed238/raw/52pojie_clean.user.js
// @downloadURL https://gist.githubusercontent.com/Hunlongyu/5eef950d53b733dd67abda224ebed238/raw/52pojie_clean.user.js
// @supportURL https://gist.github.com/Hunlongyu/5eef950d53b733dd67abda224ebed238
// @note 2019/06/27 新增自动签到。
// ==/UserScript==
(function() {
'use strict';
// Your code here...
const css = `
/* 页面背景 */
body{ background: none !important }
/* 顶部工具条 */
#toptb{ display: none !important; }
/* 版规 */
.bml{ display: none; }
/* 帖内广告:水平 + 竖直 */
.dnch_eo_pt, .dnch_eo_pr{ display: none !important; }
/* 用户签名 + 签名下的提示 */
.sign, .dnch_eo_pb{ display: none !important; }
/* 底部免责声明 */
.res-footer-note{ display: none !important; }
/* 底部广告 */
.dnch_eo_f{ display: none !important; }
/* 回帖框背景图 */
#f_pst #fastpostmessage{ background: none !important }
`
try {
GM_addStyle(css)
} catch(e) {
console.log('脚本失效,刷新后重试。', e)
}
const p = {
befor: 'qds.png',
after: 'wbs.png',
afterImg: '<img src="https://www.52pojie.cn/static/image/common/wbs.png" class="qq_bind" align="absmiddle" alt="">',
ajax: 'home.php?mod=task&do=apply&id=2',
hide: `.qq_bind{ display: none }`,
show: `.qq_bind{ display: inline-block }`,
repeat: '本期您已申请过此任务',
success: '任务已完成'
}
window.onload = function() {
const imgDom = document.querySelector('.qq_bind')
const img = imgDom.src.substring(imgDom.src.length - 7)
if (img === p.after) {
console.log('『净网卫士』 已经签到完毕!')
return false;
}
if (img === p.befor) {
console.log('『净网卫士』 尝试自动签到中……')
GM_addStyle(p.hide)
const a = new Ajax()
a.getHTML(p.ajax, function(res) {
if (res.indexOf(p.success) > 0 || res.indexOf(p.repeat) > 0) {
imgDom.parentNode.outerHTML = p.afterImg
GM_addStyle(p.show)
console.log('『净网卫士』 自动签到成功!')
} else {
console.log('『净网卫士』 自动签到失败,请手动签到!')
}
})
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment