// ==UserScript== // @name FaviconizeTheWeb // @description Adds a favicon for the website next to every external link on the page. Clearly shows when you will be leaving the current site, and where you will be going! (Unfortunately making links longer than expected can result in unwanted overflow on various websites. For example, Google header bar!) // @downstreamURL http://userscripts.org/scripts/source/60833.user.js // @namespace FTW // @include * //// Awesome websites already provide favicons: // @exclude http://www.delicious.com/search* // @exclude https://www.delicious.com/search* // @exclude http://duckduckgo.com/* // @exclude https://duckduckgo.com/* //// Not possible due to content policy // @exclude https://github.com/* //// Causes login dialogs to open! // @exclude http://www.jobs.ac.uk/* // @version 1.5.6 // @downloadURL https://update.greasyfork.icu/scripts/7665/FaviconizeTheWeb.user.js // @updateURL https://update.greasyfork.icu/scripts/7665/FaviconizeTheWeb.meta.js // ==/UserScript== // Based on FaviconizeGoogle. // == Config == // var placeFaviconAfter = false; var placeFaviconInsideLink = false; var scaleIcon = 0.75; var initialDelay = 1000; var delayIncrement = 5; // after 200 links the delay between batches will be 1 second var batchSize = 10; var alwaysUseGoogle = false; // Uses a google service to load the favicon images if (!alwaysUseGoogle) { // We can speed up if we are requesting from multiple sites initialDelay = 100; delayIncrement = 5; } if (document.location.host.indexOf(".google.") >= 0) { scaleIcon = 1.0; // return; // REMOVE THIS TO RUN ON GOOGLE! //// For search results pages with late loading results via AJAX. initialDelay = 1000; // Pause to wait for AJAX results (e.g. going back to a URL where search terms were modified and updated in the # part). // TODO: The proper way to deal with AJAX is to watch for DOMNodeInserted event. } // CHANGELOG // 2012-10.15 Applied CSS rules to elements, to override more specific page rules. // BUG: When a link only just fits inside its container, adding the favicon may // cause the container to grow or overflow or wrap! This can look very messy // if the site uses a strict CSS layout. We have a fix for Google; can we // detect in general when this fix should be employed? (AVOID_OVERFLOW) // == Library Functions == // if (typeof GM_log == 'undefined' && typeof console != 'undefined' && typeof console.log == 'function') { GM_log = function(x) { console.log(x); }; } function setBatchTimeout(callbackFn,delay) { // Rather dodgy implementation of batch processing ;) if (Math.random()>(1.0/batchSize)) // 0.0 locks up the browser on large pages with many favicons callbackFn(); else setTimeout(callbackFn,delay); } function getElementsByTagNameAndClassName(tN,cN) { return filterListBy( document.getElementsByTagName(tN), function(x){ return x.className==cN } ); } function getElementsByClassName(cN) { return getElementsByTagNameAndClassName("*",cN); } function checkAncestorsForId(node, id) { while (node = node.parentNode) { if (node.id == id) { return true; } } return false; } function filterListBy(l,c) { var ret = []; for (var i=0;i