Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyonodi committed Jul 13, 2014
2 parents 5deac5d + 841015b commit b9445fb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
32 changes: 21 additions & 11 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

// Add listener for pageaction
chrome.pageAction.onClicked.addListener(function(tab) {
/**
* Listener Callbacks
*/
var pageActionListener = function(tab) {
var destination,
commentURL,
tabId,
Expand All @@ -16,19 +17,18 @@ chrome.pageAction.onClicked.addListener(function(tab) {

// navigate tab to new url
chrome.tabs.update(tabId, {url: destination});
});
}

// listens for messages passed when chrome storage is altered
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {

var messageListener = function(message, sender, sendResponse) {
var tabName;

clickFlag = true;
mostRecentComment = message;

});
}

// tab change listener runs URL checking function
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
var tabUpdateListener = function(tabId, changeInfo, tab) {
var isLoading,
tabName;

Expand All @@ -46,9 +46,19 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
// turn clickFlag off
clickFlag = false;
}
} );
}

// create array to which all scraped pages are pushed

/**
* Vars and Events
*/
var tabList = Object(),
mostRecentComment,
clickFlag;

// Add listener for pageaction
chrome.pageAction.onClicked.addListener( pageActionListener );
// listens for messages passed when chrome storage is altered
chrome.runtime.onMessage.addListener( messageListener );
// tab change listener runs URL checking function
chrome.tabs.onUpdated.addListener( tabUpdateListener );
21 changes: 12 additions & 9 deletions hackernews.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// takes a post link and returns its comment url
/**
* Functions
*/
function getCommentURL( linkToPost ) {
var postCell,
postRow,
Expand Down Expand Up @@ -37,18 +39,22 @@ function nodelistToArray( nodelist ) {
return array;
}

// send comment url
function messenger( message ) {
chrome.runtime.sendMessage( message );
}


/**
* Vars and Events
*/
var linkList,
linkArray;

// grab all links including "more" link and convert to array of objects
linkList = document.querySelectorAll( "td.title a" );
linkArray = nodelistToArray( linkList );

function messenger( message ) {
// send comment url
chrome.runtime.sendMessage( message );
}

// use < to omit "more"
for (var i = 0; i < linkArray.length; i++) {
var link,
Expand All @@ -63,6 +69,3 @@ for (var i = 0; i < linkArray.length; i++) {

}
};



2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Back to the Comments",
"description": "When browsing hacker news this extension allows users to quickly navigate back to the comments of an item once it has been clicked through to.",
"version": "0.2.1",
"version": "0.3.0",

"permissions": [
"tabs","<all_urls>","storage"
Expand Down

0 comments on commit b9445fb

Please sign in to comment.