CH CrowdSource-OneSpace Favicon

Replaces OneSpace favicon with a nicer-looking version.

  1. // ==UserScript==
  2. // @name CH CrowdSource-OneSpace Favicon
  3. // @description Replaces OneSpace favicon with a nicer-looking version.
  4. // @version 1.0c
  5. // @author clickhappier
  6. // @namespace clickhappier
  7. // @include https://work.crowdsource.com/*
  8. // @include https://work.onespace.com/*
  9. // @require http://code.jquery.com/jquery-latest.min.js
  10. // @grant GM_log
  11. // ==/UserScript==
  12.  
  13. // CrowdSource rebranded themselves as OneSpace on 11/17/2015. Their new favicon
  14. // for both the work platform and their forums is an orange box with a white logo.
  15. // I'm not particularly fond of it, and want the work platform to have a different
  16. // favicon than the forum to better distinguish my tabs, so I made this userscript
  17. // (based on my favicon userscript for MTurk) to switch it to a better logo version.
  18. //
  19. // Adapted from 'RTM Favicon Redesigned' by Tyler Sticka circa 2009-2010: http://userscripts-mirror.org/scripts/show/42247
  20.  
  21. // create the favicon element
  22. var faviconElem = document.createElement('link');
  23. faviconElem.rel = 'shortcut icon';
  24. faviconElem.type = 'image/x-icon';
  25. // 64-bit text-encoded copy of improved favicon file's data (created from https://work.onespace.com/static/work-station/img/svg/logo_footer.svg ):
  26. faviconElem.href = 'data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD//////////////////////Pv2/+fjv//+/vz///////7+/P////7//////////////////////////////////////////////////v79///////KwHD/xbpj//Px3////////v79//7+/P////////////////////////////////////////////7+/P//////4dyx/6ydJf+3qT3/18+T//v69P////////7+/////////////////////////////////////////v7///////j14//DsDn/t6g4/7CiMf++slD/5uK8//////////7/////////////////////////////////+/3+///////I3f3/dpef/7aqQf/BrTT/tqc4/7CgKP/c1aD///////7+/P//////////////////////+/3////////E2fj/Nn/n/yh68/9LiNP/jp15/7erQ/+1pjX/w7he/////////////////////////////f7///////+50/f/MHzn/zJ96P88guT/KHv4/0WG3P+yqUr/uKk5/7eqP//08eD///////7+/f///////v7///////+syvb/LHnn/zN+6P87guf/Knnr/0uGyf+xqU3/uqo1/7irQv+xoiz/3tel///////+/vz////////////2+f7/P4Xp/zB85/86g+n/JHTj/2Cd+v/IwoH/uKYq/7aqQ/+zpjf/tac7/+voyv///////v79///////9/v///////3Sn7/8seuf/Lnrn/3Ci6//+////5eC6/7CjNP+5qTj/xLNE//bw0f///////f39/////////////P3///////+sy/b/JnPl/0eU7v+Uz/r/8fv///n26//Crzr/qqRJ/2WX0P/E3P/////8//7///////////////3+////////4Or7/0aW7/9fufn/Wrb5/2G4+f+54f7/tbiG/0aDzP8oevP/LXnj/3Wn8P/e6vv///////7+/////////v/////////N6v7/cL/6/1az+f9dtvn/Xbn5/1Gh9f8teev/O4Pm/zN+6P8ldeb/vNX3///////9/v/////////////+/v////////b7//+o2Pz/X7f5/1m2+f9dsPX/OoHn/y575/81f+j/yNz5///////9/v////////////////////////3+///+/v///////+Tz/v+Ky/v/Xbf5/zeF6v8+hOn/0eL6///////8/f///////////////////////////////////v////3+/////////////8Pm/v9jpvH/0OD5///////7/f//////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==';
  27.  
  28. // add this favicon to the head
  29. headElem = document.getElementsByTagName('head')[0];
  30. headElem.appendChild(faviconElem);
  31.  
  32. // remove any existing favicons
  33. var headLinks = headElem.getElementsByTagName('link');
  34. for (var i=0; i < headLinks.length; i++)
  35. {
  36. if ( headLinks[i].href == faviconElem.href )
  37. {
  38. return;
  39. }
  40. if ( headLinks[i].rel == "shortcut icon" || headLinks[i].rel == "icon" )
  41. {
  42. headElem.removeChild(headLinks[i]);
  43. }
  44. }
  45.  
  46. // force browser to acknowledge change
  47. var shim = document.createElement('iframe');
  48. shim.width = shim.height = 0;
  49. document.body.appendChild(shim);
  50. shim.src = "icon";
  51. document.body.removeChild(shim);