Chain Warn

description

当前为 2018-08-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         Chain Warn
// @namespace    namespace
// @version      0.2
// @description  description
// @author       tos
// @match        *.torn.com/*
// @grant        GM_addStyle
// @run-at       document-end
// ==/UserScript==

const alert_time = 120 //seconds

GM_addStyle(`
.cw_overlay {
  position: absolute;
  pointer-events: none;
  height: 100%;
  width: 100%;
  z-index: 20000;
  will-change: background-color;
}

.cw_warn {
  animation-name: cw_warn;
  animation-duration: 1.5s;
  animation-iteration-count: infinite;
}

@keyframes cw_warn {
  0% {
    background-color: #FF000000;
  }
  50% {
    background-color: #FF000055;
  }
  100 {
    background-color: #FF000000;
  }
}
`)

console.log($('.content.responsive-sidebar-container').height())
document.querySelector('body').insertAdjacentHTML('afterbegin', `<div class="cw_overlay"></div>`)
const warn_overlay = document.querySelector('.cw_overlay')

const observer = new MutationObserver((mutations) => {
  for (const mutation of mutations) {
    try {
      if (mutation.target.parentElement.className.includes('bar-timeleft')) {
        const text_t = mutation.target.data.split(':')
        const t = text_t.map(x => parseInt(x))
        if(t.length === 3) continue
        if (t[0] * 60 + t[1] < alert_time) warn_overlay.classList.add('cw_warn')
        else warn_overlay.classList.remove('cw_warn')
      }
    } catch (err) { console.log(err) }
  }
})
const chain_bar = document.querySelector('[class^=chain-bar] [class^=bar-stats]')
if (chain_bar) observer.observe(chain_bar, { subtree: true, characterData: true })

setTimeout(()=>{warn_overlay.style.height = $('body').height()+ 'px'}, 3000)

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址