Skip to content

Commit

Permalink
[LinkGrabber[ Add support for vote pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bitWolfy committed Jul 31, 2023
1 parent 052d25a commit 261b15f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/components/LinkGrabber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class LinkGrabber extends Component {

public constructor() {
super({
constraint: [PageDefinition.changes, PageDefinition.comments.list],
constraint: [PageDefinition.changes, PageDefinition.comments.list, PageDefinition.votes.comment, PageDefinition.votes.post],
waitForDOM: true,
});
}
Expand All @@ -23,6 +23,10 @@ export default class LinkGrabber extends Component {
const latest = $("article.comment").first();
if(!latest.length) return;
id = parseInt(latest.data("commentId")) || null;
} else if(Page.matches(PageDefinition.votes.comment) || Page.matches(PageDefinition.votes.post)) {
const latest = $("#votes tbody tr td").first();
if(!latest.length) return;
id = parseInt(latest.text());
} else return;

if(!id) return;
Expand Down
5 changes: 5 additions & 0 deletions src/js/models/data/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ export const PageDefinition = {
new: /^\/bans\/new/,
},

votes: {
comment: /^\/comment_votes\/?/,
post: /^\/post_votes\/?/,
},

// Custom
pluginSettings: /^\/plugins\/remt.*/,
};
Expand Down

0 comments on commit 261b15f

Please sign in to comment.