Skip to content

Commit

Permalink
Merge pull request #13 from CCEM/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Morgan Nomura authored Jun 13, 2017
2 parents e8edbb5 + d7eb669 commit 2b97a2d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion extension/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// this is the background code...

// listen for our browerAction to be clicked
// listen for our browserAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
Expand Down
20 changes: 15 additions & 5 deletions extension/inject.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
(function() {
let $grabFromPage = $('div.commentarea div.md p')
let $grabFromPage = $('div.commentarea div.md')
let textToEval = {};
$grabFromPage.addClass(function(index){
return 'reddex' + index;
});
// console.log($grabFromPage)
$grabFromPage.each(function(index){
textToEval[$grabFromPage[index].className] = $grabFromPage[index].innerText;
textToEval[$grabFromPage[index].className.split(' ')[1]] = $grabFromPage[index].innerText;
});
console.log(textToEval)
$.post('https://reddex.herokuapp.com/inbound', textToEval, function(response){
console.log(response)
for(key in response){
$('.' + key).addClass(function(index){
if(response[key] <= -.3){
return 'neg1'
}
else if(response[key] > 0.3){
return 'pos1'
}
else{
return 'neu'
}
})
}
});
// document.body.style.backgroundColor="red";

})();
5 changes: 3 additions & 2 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
],
"content_scripts": [
{
"matches": ["https://*.reddit.com/r/*"],
"js": ["jquery-3.2.1.min.js", "inject.js"]
"matches": [ "https://*.reddit.com/r/*" ],
"js": [ "jquery-3.2.1.min.js", "inject.js" ],
"css": [ "styles.css" ]
}
],
"web_accessible_resources": ["inject.js"]
Expand Down
26 changes: 26 additions & 0 deletions extension/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*styles*/
div.neg1 {
border-style: solid !important;
border-width: 2px !important;
border-color: rgba(255, 0, 0, 0.5) !important;
}
div.neg2 {
border-style: solid !important;
border-width: 2px !important;
border-color: rgba(255, 0, 0, 0.7) !important;
}
div.pos1 {
border-style: solid !important;
border-width: 2px !important;
border-color: rgba(0, 245, 33, 0.5) !important;
}
div.pos2 {
border-style: solid !important;
border-width: 2px !important;
border-color: rgba(0, 245, 33, 0.7) !important;
}
div.neu {
border-style: solid !important;
border-width: 2px !important;
border-color: rgba(0, 78, 245, 0.7) !important;
}

0 comments on commit 2b97a2d

Please sign in to comment.