Skip to content

Commit

Permalink
* General code/comment cleanup
Browse files Browse the repository at this point in the history
* Filter for "ci=" and "tid=" to find coremetrics tags. Just filtering
  on "ci=" was catching a few other requests that were not Coremetrics.
  • Loading branch information
dialmaster committed Apr 29, 2013
1 parent 1c2b1d9 commit 36deb36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions gettags.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ var ourTabId;
// We need to receive the tabID for the new window that this extension creates to display the tag data.
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
console.log('Hey, the background script got a message!' +request.greeting);
ourTabId = request.greeting;
// If the message contains a cmTagWindowID, it the one we were waiting for. This is our output window.
if (request.cmTagTabID) {
console.log('Display window registered with background script. Tab ID is ' +request.cmTagTabID);
ourTabId = request.cmTagTabID;
}
}
);

// Listen for HTTP requests. Filter on eluminate and then send the data to our window
// Listen for HTTP requests. Assume a request with 'ci=' and 'tid=' is a coremetrics request
chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) {
console.log('Request: ' + details.url);
var siteUrl = details.url.split('/')[2];
if (details.url.indexOf("ci=") != -1) {
if (details.url.indexOf("ci=") != -1 && details.url.indexOf("tid=") != -1) {
var queryString = {};

var theseParams = details.url.split("?")[1];
Expand Down
5 changes: 3 additions & 2 deletions tagwindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ document.addEventListener('DOMContentLoaded', function () {
});


// Get current tabid and send it as a message to the background as a 'greeting'
// Get current tabid and send it as a message to the background script. The background
// script NEEDs this in order to send messages to this script
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
chrome.extension.sendMessage({greeting: tabs[0].id}, function(response) {
chrome.extension.sendMessage({cmTagTabID: tabs[0].id}, function(response) {
console.log(response);
});
} );
Expand Down

0 comments on commit 36deb36

Please sign in to comment.