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() {
|
$(document).ready(function() {
|
||||||
let showOPLinks = function() {
|
let threadPageOp;
|
||||||
let OP;
|
if (active_page === "thread") {
|
||||||
|
threadPageOp = parseInt($('div.post.op a.post_no:eq(1)').text());
|
||||||
|
}
|
||||||
|
|
||||||
if ($('div.banner').length == 0) {
|
let showOPLinks = function() {
|
||||||
OP = parseInt($(this).parent().find('div.post.op a.post_no:eq(1)').text());
|
// Use the cached op if we're in a thread, otherwise fetch it.
|
||||||
} else {
|
let localOp = threadPageOp ? threadPageOp : parseInt($(this).parent().find('div.post.op a.post_no:eq(1)').text());
|
||||||
OP = parseInt($('div.post.op a.post_no:eq(1)').text());
|
|
||||||
}
|
|
||||||
|
|
||||||
$(this).find('div.body a:not([rel="nofollow"])').each(function() {
|
$(this).find('div.body a:not([rel="nofollow"])').each(function() {
|
||||||
let postID = $(this).text().match(/^>>(\d+)$/);
|
let postID = $(this).text().match(/^>>(\d+)$/);
|
||||||
|
|
||||||
if (postID) {
|
if (postID) {
|
||||||
postID = postID[1];
|
postID = parseInt(postID[1]);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postID == OP) {
|
if (postID === localOp) {
|
||||||
$(this).after(' <small>(OP)</small>');
|
$(this).after(' <small>(OP)</small>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue