diff --git a/js/show-op.js b/js/show-op.js
index 161e76e4..6f3bc850 100644
--- a/js/show-op.js
+++ b/js/show-op.js
@@ -21,31 +21,29 @@ $(document).ready(function() {
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());
+ let localOp = threadPageOp ? threadPageOp : parseInt($(this).parent().parent().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+)$/);
+ let postID = $(this).text().match(/^>>(\d+)$/);
- if (postID) {
- postID = parseInt(postID[1]);
- } else {
- return;
- }
+ if (postID) {
+ postID = parseInt(postID[1]);
+ } else {
+ return;
+ }
- if (postID === localOp) {
- $(this).after(' (OP)');
- }
- });
+ if (postID === localOp) {
+ $(this).after(' (OP)');
+ }
};
- $('div.post.reply').each(showOPLinks);
+ $('div.post.reply > div.body a:not([rel="nofollow"])').each(showOPLinks);
// allow to work with auto-reload.js, etc.
$(document).on('new_post', function(e, post) {
- if ($(post).is('div.post.reply')) {
+ if ($(post).is('div.post.reply > div.body a:not([rel="nofollow"])')) {
$(post).each(showOPLinks);
} else {
- $(post).find('div.post.reply').each(showOPLinks);
+ $(post).find('div.post.reply > div.body a:not([rel="nofollow"])').each(showOPLinks);
}
});
});