Skip to content

Instantly share code, notes, and snippets.

@KingCprey
Created May 22, 2017 16:45
Show Gist options
  • Save KingCprey/c02c44be2a731614662445390f7a1857 to your computer and use it in GitHub Desktop.
Save KingCprey/c02c44be2a731614662445390f7a1857 to your computer and use it in GitHub Desktop.
Turn Google Docs icons into random siege characters
javascript:(function(){
function ranchoice(arr){return arr[Math.floor(Math.random()*arr.length)];}
function getval(prop){
if(prop instanceof Array){return ranchoice(prop);
}else{return prop;}
}
function change(div,name,pic){
if(pic==null&&typeof(name)==="object"){
if(name.hasOwnProperty("pic")){pic=getval(name.pic);}
if(name.hasOwnProperty("name")){name=getval(name.name);}
}
div.setAttribute("data-tooltip",name);
div.setAttribute("aria-label",name);
const img=div.querySelector("img");
if(img!=null){
img.setAttribute("alt",name);
if(pic!=null){img.setAttribute("src",pic);}
}
}
function isAnon(div){return !div.hasAttribute("data-userid");}
function setDivIcons(divs,characters){for(let i=0;i<divs.length;i++){change(divs[i],ranchoice(characters));}}
function getUserDivs(){return document.querySelectorAll(".docs-presence-plus-collab-widget-container.goog-inline-block.docs-presence-plus-collab-widget-focus");}
/*set anon_only to true to stop those that are logged in from being affected*/
function setDocIcons(characters,anon_only){
if(anon_only==null){anon_only=false;}
let divs=getUserDivs();
var filter=Array.prototype.filter;
if(anon_only){divs=filter.call(divs,isAnon);}
setDivIcons(divs,characters);
}
var siege_chars=[
{
name:"Anonymous Twitch",
pic:"https://i.imgur.com/u0NN3ic.jpg"
},
{
name:"Anonymous Valkyrie",
pic:"https://i.imgur.com/3wji8gY.jpg"
},
{
name:[
"Anonymous Laser Soights",
"Anonymous Thatcher"
],
pic:"https://i.imgur.com/Nrv9QDO.jpg"
},
{
name:"Anonymous Thermite",
pic:"https://i.imgur.com/GZTF8XL.jpg"
},
{
name:[
"EL EM GEE",
"Lord Chanka",
"Anonymous Chanka",
"Anonymous Tachanka"
],
pic:"https://i.imgur.com/2HHAsCq.jpg"
},
{
name:[
"Anonymous Smoke",
"Anonymous Canister"
],
pic:"https://i.imgur.com/VdcqVXz.jpg"
},
{
name:"Anonymous Smoke",
pic:"https://i.imgur.com/VdcqVXz.jpg"
},
{
name:"Anonymous Rook",
pic:"https://i.imgur.com/rmoZ4ej.jpg"
},
{
name:"Anonymous Sledge",
pic:"https://i.imgur.com/Ekr0ys4.jpg"
},
{
name:"Anonymous Pulse",
pic:"https://i.imgur.com/cO33DSv.jpg"
},
{
name:"Anonymous Recruit",
pic:"https://i.imgur.com/2uBKTpk.jpg"
},
{
name:"Anonymous Mute",
pic:"https://i.imgur.com/HCYRgAo.jpg"
},
{
name:"Anonymous Kapkan",
pic:"https://i.imgur.com/FjnigrC.jpg"
},
{
name:"Anonymous Montagne",
pic:"https://i.imgur.com/iz1xKNW.jpg"
},
{
name:"Anonymous Jager",
pic:"https://i.imgur.com/M0sOzYj.jpg"
},
{
name:"Anonymous Glaz",
pic:"https://i.imgur.com/z6MjmJv.jpg"
},
{
name:[
"Anonymous IQ",
"Anonymous BATTERIES"
],
pic:"https://i.imgur.com/TpVOeIB.jpg"
},
{
name:[
"Anonymous Fuze",
"Anonymous HOSTAGE KILLA"
],
pic:"https://i.imgur.com/MIOjKwd.jpg"
},
{
name:"Anonymous Doc",
pic:"https://i.imgur.com/smj304b.jpg"
},
{
name:"Anonymous Twitch",
pic:"https://i.imgur.com/7Bi2Alo.jpg"
},
{
name:"Anonymous Caveira",
pic:"https://i.imgur.com/9cr3mjH.jpg"
},
{
name:"Anonymous Castle",
pic:"https://i.imgur.com/6botNSO.jpg"
},
{
name:"Anonymous Capitaoooo",
pic:"https://i.imgur.com/RZQ7niQ.jpg"
},
{
name:"Anonymous Buck",
pic:"https://i.imgur.com/lp1LfSt.jpg"
},
{
name:"Anonymous Blitz",
pic:"https://i.imgur.com/WBVXGGu.jpg"
},
{
name:"Anonymous Blackbeard",
pic:"https://i.imgur.com/PUQLwHL.jpg"
},
{
name:["Anonymous Drugs","Anonymous Blitz"],
pic:"https://i.imgur.com/LwIzZOE.jpg"
},
{
name:"Anonymous Ash",
pic:"https://i.imgur.com/RhJtloj.jpg"
}
];
setDocIcons(siege_chars);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment