Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #3 from agentlame/master
Browse files Browse the repository at this point in the history
.getThingInfo() > always check entry before thing
  • Loading branch information
agentlame committed Jul 7, 2013
2 parents dcc1465 + bf7db40 commit 84d77aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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": "reddit Moderator Toolbox",
"description": "A set of tools to be used by moderators on reddit in order to make their jobs easier.",
"version": "0.12",
"version": "0.13",

"permissions": [
"https://*.reddit.com/",
Expand Down
16 changes: 8 additions & 8 deletions tbutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,29 +317,29 @@ function main() {
};

TBUtils.getThingInfo = function (thing, modCheck) {
var entry = $(thing).closest('.entry');
var entry = $(thing).closest('.entry') || thing;

if (!$(thing).hasClass('thing')) {
thing = $(thing).closest('.thing') || thing;
}

var user = $(thing).find('.author:first').text() || $(entry).find('.author:first').text();
subreddit = $(thing).find('.subreddit').text() || reddit.post_site || $(entry).find('.subreddit').text();
permalink = $(thing).find('a.bylink').attr('href') || $(thing).find('.buttons:first .first a').attr('href') || $(entry).find('a.bylink').attr('href') || $(entry).find('.buttons:first .first a').attr('href');
domain = ($(thing).find('span.domain:first').text() || $(entry).find('span.domain:first').text()).replace('(', '').replace(')', '');
var user = $(entry).find('.author:first').text() || $(thing).find('.author:first').text();
subreddit = reddit.post_site|| $(entry).find('.subreddit').text() || $(thing).find('.subreddit').text();
permalink = $(entry).find('a.bylink').attr('href') || $(entry).find('.buttons:first .first a').attr('href') || $(thing).find('a.bylink').attr('href') || $(thing).find('.buttons:first .first a').attr('href');
domain = ($(entry).find('span.domain:first').text() || $(thing).find('span.domain:first').text()).replace('(', '').replace(')', '');

if (TBUtils.isEditUserPage && !user) {
user = $(thing).closest('.user').find('a:first').text() || $(entry).closest('.user').find('a:first').text();
user = $(entry).closest('.user').find('a:first').text() || $(thing).closest('.user').find('a:first').text();
}

// If we still don't have a sub, we're in mod mail, or PMs.
if (!subreddit) {
subreddit = ($(thing).find('.head a:last').text() || $(entry).find('.head a:last').text()).replace('/r/', '').replace('/', '').trim();
subreddit = ($(entry).find('.head a:last').text() || $(thing).find('.head a:last').text()).replace('/r/', '').replace('/', '').trim();

//user: there is still a chance that this is mod mail, but we're us.
//This is a weird palce to go about this, and the conditions are strange,
//but if we're going to assume we're us, we better make damned well sure that is likely the case.
if (!user && ($(thing).find('.remove-button') || $(entry).find('.remove-button')).text() === '') {
if (!user && ($(entry).find('.remove-button') || $(thing).find('.remove-button')).text() === '') {
user = reddit.logged;

if (!subreddit) {
Expand Down

0 comments on commit 84d77aa

Please sign in to comment.