Permalink
Browse files

Disable companion on self posts.

No longer automatically opens on self posts. You can still open by
clicking the companion icon. Added domain attribute to info object.
  • Loading branch information...
1 parent d81eb29 commit 8f93d93a5398cb64a81cd3ecbb3705b9fe1e2a5a @mhweaver mhweaver committed with Jul 16, 2011
Showing with 8 additions and 2 deletions.
  1. +5 −1 src/background.js
  2. +3 −1 src/redditContent.js
View
@@ -382,7 +382,11 @@ chrome.extension.onRequest.addListener(function(request, sender, callback) {
switch (request.action) {
case 'thingClick':
console.log('Thing clicked', request)
- redditInfo.setURL(request.url, request.info)
+ if (request.info.domain == ('self.' + request.info.subreddit)) {
+ console.log('Ignoring self post', request.info)
+ } else {
+ redditInfo.setURL(request.url, request.info)
+ }
break
}
})
@@ -31,7 +31,9 @@ function scrapeThingInfo(thing) {
info.num_comments = parseInt(thing.querySelector('.comments').innerText) || 0
info.permalink = thing.querySelector('.comments').href.match(/.*reddit.com(\/.+)/)[1]
-
+
+ info.domain = thing.querySelector('.domain > a').innerText
+
console.log('Scraped info from page:', info)
return info
}

0 comments on commit 8f93d93

Please sign in to comment.