Skip to content

Commit

Permalink
Merge pull request JupiterBroadcasting#2 from ShaneQful/master
Browse files Browse the repository at this point in the history
More JSLint fixes, only thing left is the regexes
  • Loading branch information
rikai committed Sep 23, 2012
2 parents d4998ec + 04af4f8 commit 759cd29
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions chrome/content/geturl.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
(function(){
(function () {
'use strict';
var urlChangeListener = {
onLocationChange: function(aWebProgress, aRequest, aLocation) {
var url,tag,sites,s,win;
onLocationChange: function (aWebProgress, aRequest, aLocation) {
var url, tag, sites, s, win;
if (aLocation) {
url = aLocation.spec;
tag = null;
sites = {
amazon: { rx: /^http.*?\.amazon.com.*?(\/dp\/|obidos.tg.detail|.gp.product)/i, tag:"tag=thelinactsho-20"},
amazonuk: { rx: /^http.*?\.amazon.co.uk.*?(\/dp\/|obidos.tg.detail|.gp.product)/i, tag:"tag=jupitebroadc-21"},
amazonde: { rx: /^http.*?\.amazon.de.*?(\/dp\/|obidos.tg.detail|.gp.product)/i, tag:"tag=jupitebroad02-21"},
audible: { rx: /^http.*?\.audible.com/i, tag:"source_code=COMA0230WS012110&AID=10298646&PID=4897915"},
mint: { rx: /^http.*?\.mint.com/i, tag:"PID=4897915&priorityCode=4216102399&source=cj_pfm"},
bestbuy: { rx: /^http.*?\.bestbuy.com.site.*?\?id=/i, tag:"AID=10483113&PID=4897915&ref=39&CJPID=4897915&loc=01"},
thinkgeek: { rx: /^http.*?\.thinkgeek.com/i, tag:"cpg=cj&ref=&CJURL=&CJID=3282554"},
neweggcom: { rx: /^http.*?\.newegg.com.(product.product.aspx\?item=|special.shellshocker.aspx\?)/i, tag:"nm_mc=AFC-C8Junction&cm_mmc=AFC-C8Junction-_-Branding-_-na-_-na&AID=10440554&PID=4897915"},
neweggca: { rx: /^http.*?\.newegg.ca.(product.product.aspx\?item=|special.shellshocker.aspx\?)/i, tag:"nm_mc=AFC-C8junctionCA&cm_mmc=AFC-C8JunctionCA-_-homepage-_-na-_-na&AID=10606701&PID=4897915" },
guitarcenter: { rx: /^http.*?\.guitarcenter.com/i, tag:"CJAID=10453836&CJPID=4897915"}

};
for(s in sites) {
if (url.match(sites[s].rx)) {
if (url.indexOf(sites[s].tag) === -1) {
win = aWebProgress.DOMWindow;

win.document.location.replace(url+(url.indexOf("?") >=0 ? "&" : "?")+sites[s].tag);

break;
amazon : { rx: /^http.*?\.amazon.com.*?(\/dp\/|obidos.tg.detail|.gp.product)/i, tag: "tag=thelinactsho-20"},
amazonuk : { rx: /^http.*?\.amazon.co.uk.*?(\/dp\/|obidos.tg.detail|.gp.product)/i, tag: "tag=jupitebroadc-21"},
amazonde : { rx: /^http.*?\.amazon.de.*?(\/dp\/|obidos.tg.detail|.gp.product)/i, tag: "tag=jupitebroad02-21"},
audible : { rx: /^http.*?\.audible.com/i, tag: "source_code=COMA0230WS012110&AID=10298646&PID=4897915"},
mint : { rx: /^http.*?\.mint.com/i, tag: "PID=4897915&priorityCode=4216102399&source=cj_pfm"},
bestbuy : { rx: /^http.*?\.bestbuy.com.site.*?\?id=/i, tag: "AID=10483113&PID=4897915&ref=39&CJPID=4897915&loc=01"},
thinkgeek : { rx: /^http.*?\.thinkgeek.com/i, tag: "cpg=cj&ref=&CJURL=&CJID=3282554"},
neweggcom : { rx: /^http.*?\.newegg.com.(product.product.aspx\?item=|special.shellshocker.aspx\?)/i, tag: "nm_mc=AFC-C8Junction&cm_mmc=AFC-C8Junction-_-Branding-_-na-_-na&AID=10440554&PID=4897915"},
neweggca : { rx: /^http.*?\.newegg.ca.(product.product.aspx\?item=|special.shellshocker.aspx\?)/i, tag: "nm_mc=AFC-C8junctionCA&cm_mmc=AFC-C8JunctionCA-_-homepage-_-na-_-na&AID=10606701&PID=4897915" },
guitarcenter : { rx: /^http.*?\.guitarcenter.com/i, tag: "CJAID=10453836&CJPID=4897915"}
};
for (s in sites) {
if (sites.hasOwnProperty(s)) {
if (url.match(sites[s].rx)) {
if (url.indexOf(sites[s].tag) === -1) {
win = aWebProgress.DOMWindow;
win.document.location.replace(url + (url.indexOf("?") >= 0 ? "&" : "?") + sites[s].tag);
break;
}
}
}
}
Expand All @@ -36,14 +35,13 @@
//onSecurityChange: function(webProgress, request, state) {},
//OnStateChange: function(webProgress, request, stateFlags, status) {},
//onStatusChange: function(webProgress, request, status, message) {},
QueryInterface: function(iid) {
if (!iid.equals (Components.interfaces.nsISupports) && !Iid.equals (Components.interfaces.nsIWebProgressListener)) {
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsISupports) && !Iid.equals(Components.interfaces.nsIWebProgressListener)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}

return this;
}
};

window.getBrowser().addProgressListener(urlChangeListener,Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
}());
window.getBrowser().addProgressListener(urlChangeListener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
}());

0 comments on commit 759cd29

Please sign in to comment.