Last active
April 30, 2023 06:34
-
-
Save biuuu/4ea299fb1c5cea9c5253e5695d4e9826 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 自动复制救援码 | |
// @namespace https://gist.github.com/biuuu | |
// @version 0.7 | |
// @description 自动复制最左边第一个救援码,调整顺序后刷新网页生效 | |
// @author biuuu | |
// @include /^https?:\/\/gbf\.life.*$/ | |
// @include /^https?:\/\/gbs\.eriri\.net.*$/ | |
// @include /^https?:\/\/eriri\.net\/gbs.*$/ | |
// @include /^https?:\/\/.+-raidfinder\.herokuapp\.com.*$/ | |
// @include /^https?:\/\/gbf-raidfinder\.aikats\.us.*$/ | |
// @include /^https?:\/\/gbf-raidfinder\.la-foret\.me.*$/ | |
// @include /^https?:\/\/gbf-tbw\.tk/.*$/ | |
// @include /^https?:\/\/gbraidfinder\.ogres\.cc\/home.*$/ | |
// @run-at document-end | |
// @updateURL https://blhx.shiny.fun/gbf-raidcopy.user.js | |
// @grant GM_setClipboard | |
// ==/UserScript== | |
(function () { | |
'use strict' | |
const INTERVAL = 100 // 新ID最小触发间隔 ms | |
const TAG_TIME = 5000 // 新ID标记时间 ms | |
const URL = location.href | |
const isEriri = URL.includes('eriri') | |
const isGbfLife = URL.includes('gbf.life') | |
const isOgres = URL.includes('ogres.cc') | |
let timer | |
let lastid | |
const newTag = (node) => { | |
node.classList.add('new-copied-atcp') | |
setTimeout(() => { | |
node.classList.remove('new-copied-atcp') | |
}, TAG_TIME) | |
} | |
const clickNode = (node) => { | |
if (lastid === node.dataset.raidid) return | |
clearTimeout(timer) | |
timer = setTimeout(() => { | |
lastid = node.dataset.raidid | |
node.classList.add('gbfrf-tweet--copied') | |
newTag(node) | |
GM_setClipboard(lastid, 'text') | |
}, INTERVAL) | |
} | |
const clickNodeEriri = (node) => { | |
const nodeId = node.querySelector('.tweet-battle-id') | |
if (!nodeId) return | |
clearTimeout(timer) | |
timer = setTimeout(() => { | |
lastid = nodeId.textContent | |
GM_setClipboard(lastid, 'text') | |
node.querySelector('button').classList.add('tweet-copied') | |
newTag(node) | |
}, INTERVAL) | |
} | |
const clickNodeGbfLife = (node) => { | |
const nodeId = node.querySelector('.rescue_id') | |
if (!nodeId) return | |
clearTimeout(timer) | |
timer = setTimeout(() => { | |
lastid = nodeId.textContent | |
node.classList.add('clicked') | |
newTag(node) | |
GM_setClipboard(lastid, 'text') | |
}, INTERVAL) | |
} | |
const clickNodeOgres = (node) => { | |
const nodeId = node.querySelector('mat-text>span') | |
if (!nodeId) return | |
clearTimeout(timer) | |
timer = setTimeout(() => { | |
lastid = nodeId.textContent | |
node.classList.add('raid-card-selected') | |
newTag(node) | |
GM_setClipboard(lastid, 'text') | |
}, INTERVAL) | |
} | |
const start = () => { | |
const mutationCallback = (mutationsList) => { | |
for (let mutation of mutationsList) { | |
const type = mutation.type | |
const addedNodes = mutation.addedNodes | |
if (type === 'childList' && addedNodes.length && addedNodes.length < 2) { | |
Array.from(addedNodes).reverse().forEach(node => { | |
if (node.nodeType !== Node.ELEMENT_NODE) return | |
if (isEriri) { | |
if (node.classList.contains('w-full')) { | |
clickNodeEriri(node) | |
} | |
} else if (node?.tagName?.toLowerCase() === 'mat-card') { | |
clickNodeOgres(node) | |
} else if (node.classList.contains('list-group-item')) { | |
clickNodeGbfLife(node) | |
} else if (node.dataset && node.dataset.raidid) { | |
clickNode(node) | |
} | |
}) | |
} | |
} | |
} | |
const obConfig = { | |
subtree: true, | |
childList: true | |
} | |
let selector = '.mdl-list.gbfrf-tweets' | |
if (isEriri) { | |
selector = '#gbs-main' | |
} else if (isGbfLife) { | |
selector = '.list-group' | |
} else if (isOgres) { | |
selector = 'mat-divider+div>div' | |
} | |
const targetNode = document.querySelector(selector) | |
const observer = new MutationObserver(mutationCallback) | |
observer.observe(targetNode, obConfig) | |
const addStyle = (css) => { | |
const style = document.createElement('style') | |
style.innerText = css | |
document.head.appendChild(style) | |
} | |
addStyle(` | |
.new-copied-atcp { | |
background-color: rgb(197 3 56 / 45%) !important; | |
} | |
`) | |
} | |
const main = () => { | |
setTimeout(start, 1000) | |
} | |
if (window.unsafeWindow) { | |
unsafeWindow.addEventListener('load', main) | |
} else { | |
window.addEventListener('load', main) | |
} | |
})() |
同一套代码搭的网站才行
大佬,那个TAG_TIME是不是剪贴板的过期时间,比如说我想只复制3秒内的id,把TAG_TIME改成3000就行了么?
主要是因为大巴太卷了,超过3秒的感觉就是给人做背景板了,不想进。
gbf.eriri has been upgraded.
Is it possible to update this script?
Thanks again.
忙烦大佬看看https://gbf-raidfinder.teemo.name/ 我自己通过 .ant-spin-container和 .ant-col-6取到的救援码 不知道哪来的
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你好 想问下 如果要添加别的填表网的话 要改哪些?我试着inclue gbf.life和把下面的.mdl-list.gbfrf-tweets改成了.list-group可是不行