作者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/m.aspx?n=bbs/Little-Games/M.1528643297.A.52B.html