Saw it here:
"Firefox FlashGot 1.1 "
http://fileforum.betanews.com/detail/Fi ... 87132691/1
This is FlashGot 1.2.2 with some additions.
Three files modified or added into flashgot.jar:
flashgotOverlay.xul
+ Adds: <script src="noAds.js" />
flashgotDMOverlayFF.xul
+ Adds: <script src="noAds.js" />
noAds.js
> newly added file, not part of FlashGot
Code: Select all
//*************************************************************************
// noAds
//
// File: noAds.js
// Description: main javascript of noAds extension
// Author : Mich
// Licence : see licence.txt
//*************************************************************************
if(!com) var com={};
if(!com.mich) com.mich={};
if(!com.mich.noads) com.mich.noads={};
function TestEncoding()
{
var inputString=document.forms["TestEncodingForm"]["inputString"].value;
var encodedInputString=escape(inputString);
encodedInputString=encodedInputString.replace("+", "%2B");
encodedInputString=encodedInputString.replace("/", "%2F");
document.forms["TestEncodingForm"]["encodedInputString"].value=encodedInputString;
}
com.mich.noads = {
VERSION: "2.0",
numberOfEditedLinks: 0,
noAdsTranslations: Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService).createBundle("chrome://noads/locale/JStranslation.properties"),
updateStatus : function (numberOfEditedLinks) {
/** if ( numberOfEditedLinks == 0 ){
document.getElementById('noads-status-bar-icon').setAttribute("src", "chrome://noads/skin/status-bar-off.png");
document.getElementById('noads-status-bar-icon').setAttribute("tooltiptext", "noAds " + com.mich.noads.VERSION + "\n" + "0 " + com.mich.noads.noAdsTranslations.GetStringFromName("editedlink"));
} else {
document.getElementById('noads-status-bar-icon').setAttribute("src", "chrome://noads/skin/status-bar-on.png");
if ( numberOfEditedLinks == 1 )
document.getElementById('noads-status-bar-icon').setAttribute("tooltiptext", "noAds " + com.mich.noads.VERSION + "\n" + "1 " + com.mich.noads.noAdsTranslations.GetStringFromName("editedlink"));
else
document.getElementById('noads-status-bar-icon').setAttribute("tooltiptext", "noAds " + com.mich.noads.VERSION + "\n" + numberOfEditedLinks + " " + com.mich.noads.noAdsTranslations.GetStringFromName("editedlinks"));
}*/
},
countEditedLinksInFrame: function(objFrame) {
var links = 0;
var allLinks = objFrame.getElementsByTagName("a");
for (var i=0, il=allLinks.length; i<il; i++) {
elm = allLinks[i];
if( elm.className.indexOf("noAds-link-selected", 0) != -1 || elm.className.indexOf("ads-link-selected", 0) != -1 )// déjà noAdsé
links++;
}
return links;
},
findEditedLinksInFrames: function( targetFrames ) {
if( targetFrames.length > 0 ) {
for( i = 0; i < targetFrames.length; i++ ) {
this.numberOfEditedLinks += com.mich.noads.countEditedLinksInFrame(targetFrames[i].document);
if( targetFrames[i].frames > 0 )
this.findEditedLinksInFrames( targetFrames[i].frames );
}
}
},
countEditedLinks: function() {
this.numberOfEditedLinks = 0;
this.numberOfEditedLinks += com.mich.noads.countEditedLinksInFrame(gBrowser.selectedBrowser.contentDocument);
this.findEditedLinksInFrames(gBrowser.selectedBrowser.contentWindow.frames);
//alert(this.numberOfEditedLinks)
//alert( gBrowser.selectedBrowser.contentDocument.location.href + " | " + gBrowser.selectedBrowser.contentWindow.frames.length );
},
onKeyPressed: function() {
com.mich.noads.run(window.content.document);
com.mich.noads.countEditedLinks();
com.mich.noads.updateStatus(this.numberOfEditedLinks);
},
onTabSelected: function(e) {
com.mich.noads.countEditedLinks();
com.mich.noads.updateStatus(this.numberOfEditedLinks);
},
onPageLoad: function(e) {
if (e.originalTarget instanceof HTMLDocument) {
var doc = e.originalTarget;
if (doc) {
com.mich.noads.run(doc);
com.mich.noads.countEditedLinks();
com.mich.noads.updateStatus(this.numberOfEditedLinks);
}
}
},
run: function(doc) {
var head = doc.getElementsByTagName("head")[0],
style = doc.getElementById("noAds-style"),
allLinks = doc.getElementsByTagName("a");
/**
if (!style) {
style = doc.createElement("link");
style.id = "noAds-style";
style.type = "text/css";
style.rel = "stylesheet";
style.href = "chrome://noads/skin/skin.css";
head.appendChild(style);
}
*/
for (var i=0, il=allLinks.length; i<il; i++) {
elm = allLinks[i];
//TradeDoubler
if ( elm.href.indexOf("clk.tradedoubler.com/", 0) != -1 ){
if ( elm.href.lastIndexOf("http", elm.href.length) == 0 ) {//nothingtodo
//style
if ( elm.className.indexOf("ads-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "ads-link-selected";
} else {
//url
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
}
} else
//Doubleclick (Google AdWords)
if ( elm.href.indexOf("http://googleads.g.doubleclick.net/", 0) != -1 ){
//url
var right_limit = (elm.href.indexOf("&", elm.href.lastIndexOf("http", elm.href.length)) != -1) ? elm.href.indexOf("&", elm.href.lastIndexOf("http", elm.href.length)) : elm.href.length;
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
if ( elm.href.match(".hurra.com") ) {//nothingtodo
//style
if ( elm.className.indexOf("ads-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "ads-link-selected";
} else {
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
}
} else
//Google AdSense
if ( elm.href.indexOf("/aclk?", 0) != -1 || elm.href.indexOf("/aclk%3F", 0) != -1 ) {
//url
var right_limit = (elm.href.indexOf("&", elm.href.lastIndexOf("http", elm.href.length)) != -1) ? elm.href.indexOf("&", elm.href.lastIndexOf("http", elm.href.length)) : elm.href.length;
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
} else
//Zanox
if ( elm.href.indexOf("http://ad.zanox.com/", 0) != -1 ) {
//url
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
} else
// Overture (Yahoo)
if ( elm.href.indexOf(".overture.com/", 0) != -1 && doc.location.href.indexOf("search.yahoo.com/", 0) < 11 && doc.location.href.indexOf("search.yahoo.com/", 0) >= 0 ) {
//url
elm.href = "http://";
var subelm1 = elm.nextSibling;
while (subelm1) {
if ( subelm1.nodeName == "EM" ) {
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
}
subelm1 = subelm1.nextSibling;
}
if ( elm.href == "http:///") {
subelm1 = elm.parentNode;
while (subelm1) {
if ( subelm1.nodeName == "EM" ) {
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
}
subelm1 = subelm1.nextSibling;
}
}
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
} else
// Overture (AltaVista)
if ( elm.href.indexOf(".overture.com/", 0) != -1 && doc.location.href.indexOf(".altavista.com/", 0) < 11 && doc.location.href.indexOf(".altavista.com/", 0) >= 0 ) {
//url
elm.href = "http://";
var subelm1 = elm.nextSibling;
var count = 0;
while (subelm1) {
if ( subelm1.nodeName == "SPAN") {
if ( count == 0)
count++;
else {
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
break;
}
}
subelm1 = subelm1.nextSibling;
}
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
} else
//Overture ou R.MSN (Bing)
if ( ( elm.href.indexOf(".overture.com/", 0) != -1 || elm.href.indexOf(".r.msn.com/", 0) != -1 ) && doc.location.href.indexOf(".bing.com/", 0) < 11 && doc.location.href.indexOf(".bing.com/", 0) >= 0 ) {
//url
elm.href = "http://";
var subelm1 = elm.firstChild;
while (subelm1) {
if ( subelm1.nodeName == "CITE") {
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
}
subelm1 = subelm1.nextSibling;
}
if ( elm.href == "http:///") {
subelm1 = elm.parentNode;
while (subelm1) {
if ( subelm1.nodeName == "CITE" ) {
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
}
subelm1 = subelm1.nextSibling;
}
}
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
} else
//eBuzzing
if ( elm.href.match("http://www.ebuzzing.com/") ) {
//url
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
} else
//BlogBang alone
if ( elm.href.match("http://www.blogbang.com/demo/redir.php") ) {
if ( elm.href.lastIndexOf("http", elm.href.length) == 0 && elm.href.match("&url=")) {
//url
var temp = unescape( unescape( elm.href.substring( elm.href.indexOf("&url=", 0) + 5), elm.href.length ) )
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
} else {
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
}
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
} else
//ToutLeMondeEnBlogue
if ( elm.href.match("http://www.toutlemondeenblogue.com/atrk.aspx") ) {
//url
var htstring = elm.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig, "");
elm.href = "http://www.google.com/cse?cx=partner-pub-7270384233403454%3Anllk5g-lhjj&ie=ISO-8859-1&q=" + escape(stripped) + "&sa=Search";
//style
if ( elm.className.indexOf("noAds-link-selected", 0) == -1 )
elm.className += ((elm.className.length > 0)? " " : "") + "noAds-link-selected";
}
if( doc.location.href.indexOf(".ask.com/", 0) < 11 && elm.className.indexOf("noAds-link-selected", 0) != -1) {//traitement du onmouseover chez Ask (pubs Google AdsWord)
elm.setAttribute("onmouseout", null);
elm.setAttribute("onmouseover", null);
elm.setAttribute("onmousedown", null);
}
}
}
};
addEventListener("DOMContentLoaded", function (e) { com.mich.noads.onPageLoad(e) }, true);
gBrowser.tabContainer.addEventListener("TabSelect", function (e) { com.mich.noads.onTabSelected(e) }, false);