Discussions » Creation Requests

Could Someone Help Me With Simple Script

§
Posted: 02.12.2014
Edited: 02.12.2014

Could Someone Help Me With Simple Script

Hello Greasy Fork community, I don't know about userscripts much, so i aren't sure if this is possible.

Could someone help me with very simple script? I want to change favicon on Doit.im website. It includes task count - which makes me little bit anxious.

Favicon can be anything, but preferably same icon without task count.

Thank you very, very much. :)

woxxomMod
§
Posted: 02.12.2014
Edited: 02.12.2014

I'm not sure this can be done using a userscript, because the favicon is updated via canvas drawing in the externally loaded libs.js. But this is certainly possible with Fiddler (might be easy) or a custom Firefox addon that implements nsIHttpChannel interface (definitely not easy) by tampering the js code on-the-fly.

§
Posted: 03.12.2014
Edited: 03.12.2014

Thanks for answer! I will do research on Fiddler. One question - if I change favicon with it, will it be permanent or will it revert back when i refresh site?

EDIT: I found this script to change google's favicon. if it's not too hard for you could you help me making it work for Doit.im? Thanks. Script below:

// ==UserScript==
// @name BetterFavicon
// @namespace planetargon
// @description A better favicon for google
// @include http://*.google.com/
// ==/UserScript==
 
var favicon_link_html = document.createElement('link');
favicon_link_html.rel = 'icon';
favicon_link_html.href = 'http://robbyonrails.com/files/google-favicon.ico';
favicon_link_html.type = 'image/x-icon';
 
try {
document.getElementsByTagName('head')[0].appendChild( favicon_link_html );
}
catch(e) { }
woxxomMod
§
Posted: 03.12.2014

The problem is that doit.im changes the favicon dynamically. With Fiddler you can remove that part of code. As for your userscript sample, if you don't mind an occasional flicker of the favicon it might be possible to add a timer to periodically restore the favicon.

§
Posted: 03.12.2014

I don't mind flicker at all just get rid of damn counter :D also if this is possible, it would be even better to restore favicon only when i refresh the Doit.im. They don't add counter if i don't visit today list. I just use contexts and don't visit today list at all. But if i refresh site, they still add counter. By the way, thanks for help. :)

woxxomMod
§
Posted: 03.12.2014
Edited: 03.12.2014

Doesn't flicker here.

// ==UserScript==
// @name    doit.im replace favicon
// @include https://i.doit.im/*
// @include http://i.doit.im/*
// @run-at  document-start
// @grant   none
// ==/UserScript==

window.addEventListener('DOMContentLoaded', function(e) {
  var icon = document.head.appendChild(document.createElement('link'));
  icon.href = '/favicon.ico';
  icon.rel = 'icon';

  new MutationObserver(function(mutations){
    for (var i=0, ml=mutations.length, m; (i<ml) && (m=mutations[i]); i++)
      for (var j=0, nodes=m.addedNodes, nl=nodes.length, n; (j<nl) && (n=nodes[j]); j++)
        if ((n.localName == 'link') && (n.rel == 'icon'))
          n.href = '/favicon.ico';
  }).observe(document.head, {subtree:true, childList:true});
});
§
Posted: 03.12.2014
Edited: 03.12.2014

Thanks. But it does nothing. Do I need to change something to work? Sorry if stupid question. Thanks for script again :)

woxxomMod
§
Posted: 03.12.2014
Edited: 03.12.2014

Basically you need to install it and reopen/reload the page https://i.doit.im

§
Posted: 03.12.2014

Thanks very much. :D I changed https to httpc and now it works. Doit.im doesn't run on https for some reason...

woxxomMod
§
Posted: 03.12.2014
Edited: 04.12.2014

Ah, okay. I've added both protocols to the code above just in case.

Post reply

Sign in to post a reply.