Permalink
Browse files

Handle missing reddit scripts in the header.

  • Loading branch information...
1 parent d98a3c8 commit a165e42771c014c8288403a795622a988d8e976f @snoshy snoshy committed with chromakode Jul 5, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 redditContent.js
View
@@ -42,7 +42,10 @@ function thingClicked() {
$(document).ready(function() {
const redditScript = 'var reddit';
console.log('Shine reddit content handler running.');
- $('.thing a.title').click(thingClicked);
- var modhash = $('script:contains('+redditScript+')').text().match(/modhash:\s*'(\w*)'/)[1];
- chrome.extension.sendRequest({action:'modhashUpdate', modhash:modhash});
+ $('.thing a.title').click(thingClicked);
+ var match = $('script:contains('+redditScript+')').text().match(/modhash:\s*'(\w*)'/);
+ if (match) {
+ var modhash = match[1];
+ chrome.extension.sendRequest({action:'modhashUpdate', modhash:modhash});
+ }
});

0 comments on commit a165e42

Please sign in to comment.