Greasy Fork is available in English.

『净网卫士』 吾爱破解论坛

移除广告,精简页面。新增论坛后台自动签到。

ของเมื่อวันที่ 05-07-2019 ดู เวอร์ชันล่าสุด

// ==UserScript==
// @author            Hunlongyu
// @name              『净网卫士』 吾爱破解论坛
// @namespace         https://github.com/Hunlongyu
// @icon              https://i.loli.net/2019/04/22/5cbd720718fdb.png
// @description       移除广告,精简页面。新增论坛后台自动签到。
// @version           0.3.2
// @include           *://*.52pojie.cn/*
// @grant             GM_addStyle
// @run-at            document-start
// @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('『净网卫士』 自动签到失败,请手动签到!')
                }
            })
        }
    }
})();


// ==UserScript==
// @author            Hunlongyu
// @name              『净网卫士』 Krunker 汉化版
// @namespace         https://github.com/Hunlongyu
// @icon              https://i.loli.net/2019/04/22/5cbd720718fdb.png
// @description       翻译为中文,精简页面。
// @version           0.0.1
// @include           https://krunker.io/*
// @grant             GM_addStyle
// @run-at            document-end
// @supportURL        https://gist.github.com/Hunlongyu/5c169b8ac288ca415e7068938a0fb47a
// @note              2019/06/20 v0.1.2 初始化,完成基础功能。
// ==/UserScript==

(function () {
  'use strict'

  const css = `
    * {
      font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,SimSun,sans-serif;
    }
  `
  GM_addStyle(css)

  // HEAD
  document.getElementById('signedOutHeaderBar').innerHTML = document.getElementById('signedOutHeaderBar').innerHTML
  .replace(/>Login</g, '>登录<')
  .replace(/>Register</g, '>注册<')

  // MENU
  document.getElementById('menuItemContainer').innerHTML = document.getElementById('menuItemContainer').innerHTML
  .replace(/>Profile</g, '>个人中心<')
  .replace(/>Shop</g, '>商城<')
  .replace(/>Social</g, '>社交<')
  .replace(/>Maps</g, '>地图<')
  .replace(/>Mods</g, '>模组<')
  .replace(/>Settings</g, '>设置<')

  let globalTimer = null // 全局定时器:用于监控全局弹框
  let headerLoopArray = ['Custom Maps'] // 数组内弹框需要循环翻译

  // 菜单点击事件:触发全局定时器
  let menuItems = document.querySelectorAll('.menuItem')
  for (let i = 0; i < menuItems.length; i++) {
    menuItems[i].addEventListener('click', function () {
      let header = document.getElementById('windowHeader').innerHTML
      let inOf = headerLoopArray.indexOf(header)
      if (inOf < 0) {
        globalModal(header)
      } else {
        globalLoopModal(header)
      }
    })
  }

  
  function timerEvent () {
    globalTimer = setInterval(() => {
      let flag = document.getElementById('windowHolder').style.display
      let newHeader = document.getElementById('windowHeader').innerHTML
      if (flag === 'none') {
        clearInterval(globalTimer)
        return false
      }
      console.log(oldHeader, newHeader)
      if (flag === 'block' && oldHeader === newHeader ) {
        clearInterval(globalTimer)
        globalWindowHolder(newHeader)
      } else {
        loopModal(newHeader)
      }
    }, 50)
  }

  function loopModal (e) {
    console.log(e)
    if (e === 'Custom Maps') { // 地图
      document.getElementById('windowHolder').innerHTML = document.getElementById('windowHolder').innerHTML
      .replace(/>Map Editor</g, '>地图编辑器<')
      .replace(/>Publish Map</g, '>发布地图<')
      .replace(/>Map Community</g, '>地图社区<')
      .replace(/>Hot</g, '>热门<')
      .replace(/>New</g, '>最新<')
      .replace(/>Favorites</g, '>最爱<')
      .replace(/>My Maps</g, '>我的地图<')
      .replace(/>Search</g, '>搜索<')
      .replace(/>No Maps found</g, '>没有发现地图<')
      return false
    }
  }

  // 全局弹出框事件:翻译弹框文本
  function globalModal (e) {
    if (e === 'Account') { // 个人中心
      document.getElementById('windowHolder').innerHTML = document.getElementById('windowHolder').innerHTML
      .replace(/>Name</g, '>名字<')
      .replace(/>Clan</g, '>家族<')
      .replace(/>None</g, '>无<')
      .replace(/>Level</g, '>等级<')
      .replace(/>Score</g, '>积分<')
      .replace(/>KR</g, '>KR币<')
      .replace(/>Kills</g, '>击杀<')
      .replace(/>Deaths</g, '>死亡<')
      .replace(/>KDR</g, '>击杀死亡比<')
      .replace(/>Games Played</g, '>游戏次数<')
      .replace(/>Games Won</g, '>胜利次数<')
      .replace(/>W\/L</g, '>胜利失败比<')
      .replace(/>Time Played</g, '>游戏时长<')
      .replace(/>Logout</g, '>退出账号<')
      return false
    }

    if (e === 'Store') { // 商城
      document.getElementById('windowHolder').innerHTML = document.getElementById('windowHolder').innerHTML
      .replace(/>Prize Wheels</g, '>抽奖转盘<')
      .replace(/>Unlock new weapon skins and items</g, '>解锁新的武器皮肤和物品<')
      .replace(/>By purchasing you agree to the </g, '>购买即表示您同意<')
      .replace(/>Terms</g, '>本条款<')
      .replace(/>Purchase KR</g, '>充值 KR<')
      .replace(/> Any </g, '> 所有 <')
      .replace(/> Snipers Only! </g, '> 狙击手 <')
      .replace(/> Outfits Only! </g, '> 服装 <')
      .replace(/>Popular!</g, '>流行<')
      .replace(/>Off</g, '>折扣<')
      .replace(/ in account/g, '')
      return false
    }

    if (e === 'Mod Manager') { // mod
      document.getElementById('windowHolder').innerHTML = document.getElementById('windowHolder').innerHTML
      .replace(/>Mod Guide</g, '>mod使用说明(英文版)<')
      .replace(/>Mods List</g, '>mod列表<')
      .replace(/>Publish Mod</g, '>发布mod<')
      .replace(/>Viewer</g, '>查看<')
      return false
    }
  }
})()