Skip to content

Commit

Permalink
configurations synchronized between JBAR Chrome and JBAR Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulius Gutberlet committed Feb 28, 2013
1 parent 93c1318 commit 1c802d9
Showing 1 changed file with 92 additions and 19 deletions.
111 changes: 92 additions & 19 deletions chrome/content/geturl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,102 @@
'use strict';
var urlChangeListener = {
onLocationChange: function (aWebProgress, aRequest, aLocation) {
var url, tag, sites, s, win;
var url, tag, win;
var configurations = {
amazon : {
rx: /^http.*?\.amazon.com.*?(\/dp\/|obidos.tg.detail|.gp.product)/i,
params: [
{ param: "tag", paramValue: "thelinactsho-20" }
]
},
amazonuk : {
rx: /^http.*?\.amazon.co.uk.*?(\/dp\/|obidos.tg.detail|.gp.product)/i,
params: [
{ param: "tag", paramValue: "jupitebroadc-21" }
]
},
amazonde : {
rx: /^http.*?\.amazon.de.*?(\/dp\/|obidos.tg.detail|.gp.product)/i,
params: [
{ param: "tag", paramValue: "jupitebroad02-21" }
]
},
amazonca : {
rx: /^http.*?\.amazon.ca.*?(\/dp\/|obidos.tg.detail|.gp.product)/i,
params: [
{ param: "tag", paramValue: "jbcanada-20" }
]
},
audible : {
rx: /^http.*?\.audible.com/i,
params: [
{ param: "source_code", paramValue: "COMA0230WS012110" },
{ param: "AID", paramValue: "10298646" },
{ param: "PID", paramValue: "4897915" }
]
},
mint : {
rx: /^http.*?\.mint.com/i,
params: [
{ param: "PID", paramValue: "4897915" },
{ param: "priorityCode", paramValue: "4216102399" },
{ param: "source", paramValue: "cj_pfm" }
]
},
bestbuy : {
rx: /^http.*?\.bestbuy.com.site.*?\?id=/i,
params: [
{ param: "AID", paramValue: "10483113" },
{ param: "PID", paramValue: "4897915" },
{ param: "ref", paramValue: "39" },
{ param: "CJPID", paramValue: "4897915" },
{ param: "loc", paramValue: "01" }
]
},
thinkgeek : {
rx: /^http.*?\.thinkgeek.com/i,
params: [
{ param: "cpg", paramValue: "cj" },
{ param: "ref", paramValue: "" },
{ param: "CJURL", paramValue: "" },
{ param: "CJID", paramValue: "3282554"}
]
},
neweggcom : {
rx: /^http.*?\.newegg.com.(product.product.aspx\?item=|special.shellshocker.aspx\?)/i,
params: [
{ param: "nm_mc", paramValue: "AFC-C8Junction" },
{ param: "cm_mmc", paramValue: "AFC-C8Junction-_-Branding-_-na-_-na" },
{ param: "AID", paramValue: "10440554" },
{ param: "PID", paramValue: "4897915" }
]
},
neweggca : {
rx: /^http.*?\.newegg.ca.(product.product.aspx\?item=|special.shellshocker.aspx\?)/i,
params: [
{ param: "nm_mc", paramValue: "AFC-C8junctionCA" },
{ param: "cm_mmc", paramValue: "AFC-C8JunctionCA-_-homepage-_-na-_-na" },
{ param: "AID", paramValue: "10606701" },
{ param: "PID", paramValue: "4897915" }
]
},
guitarcenter : {
rx: /^http.*?\.guitarcenter.com/i,
params: [
{ param: "CJAID", paramValue: "10453836" },
{ param: "CJPID", paramValue: "4897915" }
]
}
};
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"},
amazonca : { rx: /^http.*?\.amazon.ca.*?(\/dp\/|obidos.tg.detail|.gp.product)/i, tag: "tag=jbcanada-20"},
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) {
for (var config in configurations) {
if (configurations.hasOwnProperty(config)) {
if (url.match(configurations[config].rx)) {
if (url.indexOf("tag=") === -1) {
win = aWebProgress.DOMWindow;
win.document.location.replace(url + (url.indexOf("?") >= 0 ? "&" : "?") + sites[s].tag);
win.document.location.replace(url + (url.indexOf("?") >= 0 ? "&" : "?") + createTag(config.params));
break;
}
}
Expand Down

0 comments on commit 1c802d9

Please sign in to comment.