description
当前为
// ==UserScript==
// @name Torn Rackets
// @namespace namespace
// @version 0.1
// @description description
// @author tos
// @match *.torn.com/city.php*
// @grant GM_addStyle
// @grant GM_setClipboard
// ==/UserScript==
GM_addStyle(`
#x_button_right {
background-color: #c13c3c;
color: #eaeaea;
cursor: pointer;
padding: 1em;
position: fixed;
right: 0;
}
`)
$( document ).ajaxComplete(function(event, jqXHR, ajaxObj) {
if (ajaxObj.url && ajaxObj.url.includes('step=mapData')) {
const mapdata = JSON.parse(jqXHR.responseText)
document.querySelector('div.content').insertAdjacentHTML('beforebegin', `<div id="x_button_right">Copy Rackets (${mapdata.rackets.length})</div>`)
document.querySelector('#x_button_right').addEventListener('click', (e) => {
let csv = ''
mapdata.rackets.forEach(r => csv += r.type+'\t'+r.typeName+'\t'+r.description+'\n')
GM_setClipboard(csv)
})
}
})