作者Allenbootung (不痛)
看板Little-Games
标题Re: [分享] 射击 - surviv.io
时间Sun Jun 10 23:08:12 2018
老是忘记自己拿的枪是什麽颜色的,把这段程式码贴到console能把武器栏上色。
https://imgur.com/ifVOmQQ
// ==UserScript==
// @name surviv gun color
// @namespace
http://tampermonkey.net/
// @version 0.3
// @description try to take over the world!
// @author Allenbootung
// @match
http://surviv.io/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var elems = document.getElementsByClassName('ui-weapon-name');
console.log(elems);
for (var ii=0; ii<elems.length; ii++) {
elems[ii].addEventListener('DOMSubtreeModified', function(){
var weaponName = this.textContent;
var border = 'ridge ';//auto fire
//not autofire mode
switch(weaponName) {
//fast rate
case 'Fists':
case 'Frag':
case 'Smoke':
case 'M9'://trash
case 'MP220'://OP
case 'OT-38':
case 'Desert Eagle':
case 'M39 EMR':
case 'Mk 12 SPR':
border = 'double ';
break;
//slow rate
case 'UMP9'://trash
case 'M870':
case 'Mosin-Nagant':
case 'SV-98':
case 'FAMAS':
border = 'dashed ';
break;
}
//weapon color
switch(weaponName) {
//orange bullet 9mm
case 'M9':
case 'UMP9':
case 'MP5':
case 'Glock 18C':
case 'MAC-10':
case 'Vector':
border += 'orange';
break;
//red bullet 12gauge
case 'M870':
case 'MP220':
case 'Saiga-12':
border += 'red';
break;
//blue bullet 7.62mm
case 'OT-38':
case 'M39 EMR':
case 'Mosin-Nagant':
case 'SV-98'://ddddd
case 'AK-47':
case 'DP-28':
case 'SCAR-H':
border += 'blue';
break;
//green bullet 5.56mm
case 'FAMAS':
case 'Mk 12 SPR':
case 'HK416':
case 'M249':
border += 'green';
break;
//black bullet 50ae
case 'Desert Eagle':
border += 'black';
break;
case 'Smoke':
border += 'white';
break;
case 'Frag':
border += 'red';
break;
default:
border = '';
break;
}
console.log(border);
this.parentNode.style.border=border;
}, false);
}
})();
--
jQuery做事,开口不谈$後面啥都别想动。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.41.145.102
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Little-Games/M.1528643297.A.52B.html