forked from leftypol/leftypol
show-op.js: cache the op id in thread pages
This commit is contained in:
parent
4544107e1d
commit
da3ad44f37
1 changed files with 9 additions and 9 deletions
|
@ -14,25 +14,25 @@
|
|||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
let showOPLinks = function() {
|
||||
let OP;
|
||||
let threadPageOp;
|
||||
if (active_page === "thread") {
|
||||
threadPageOp = parseInt($('div.post.op a.post_no:eq(1)').text());
|
||||
}
|
||||
|
||||
if ($('div.banner').length == 0) {
|
||||
OP = parseInt($(this).parent().find('div.post.op a.post_no:eq(1)').text());
|
||||
} else {
|
||||
OP = parseInt($('div.post.op a.post_no:eq(1)').text());
|
||||
}
|
||||
let showOPLinks = function() {
|
||||
// Use the cached op if we're in a thread, otherwise fetch it.
|
||||
let localOp = threadPageOp ? threadPageOp : parseInt($(this).parent().find('div.post.op a.post_no:eq(1)').text());
|
||||
|
||||
$(this).find('div.body a:not([rel="nofollow"])').each(function() {
|
||||
let postID = $(this).text().match(/^>>(\d+)$/);
|
||||
|
||||
if (postID) {
|
||||
postID = postID[1];
|
||||
postID = parseInt(postID[1]);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (postID == OP) {
|
||||
if (postID === localOp) {
|
||||
$(this).after(' <small>(OP)</small>');
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue