I'm trying to change the favicon on Google's Inbox 'pinned' page to a pin. so I know which tab is which at a glance.
I am aware that there are probably extensions to do this, but I'm learning Javascript and am trying to have a go myself. I manage to change other favicons using a 'url.indexOf' command, but the Inbox Pinned page does not change the URL. So I figured I would write Javascript to look for the word "Pinned", then action the Favicon change if it is found. This is what I have:
favico = function() {
this.is_changed = 0;
this.retry = 1000;
this.timerFindButtons = null;
this.list = [
"foo",
"bar"
];
}
favico.prototype.init = function(){
setTimeout(this.looping.bind(this), this.retry);
}
favico.prototype.looping = function(){
var head = document.getElementsByTagName('head')[0];
var links = head.querySelectorAll('link');
var eles = document.querySelectorAll("div");
for(var ii=0;ii<eles.length;ii++){
var foo = eles[ii].getAttribute('jstcache');
if(foo != null && foo.indexOf('1683') != -1){
var bar = eles[ii].innerText;
if(bar.indexOf('Pinned') != -1){
links[0].setAttribute('href', 'data:image/x-icon;base64,...');
this.is_changed = 1;}
else {
this.is_changed = 0;
links[0].setAttribute('href', '//ssl.gstatic.com/bt/C3341AA7A1A076756462EE2E5CD71C11/ic_product_inbox_16dp_r2_2x.png');}
}
}
setTimeout(this.looping.bind(this), this.retry);
}
var oo = new favico()
oo.init();
What am I doing wrong? Many thanks to anyone who can help!