From 5b108ce929f59e70b60928884f927672fd7bfef4 Mon Sep 17 00:00:00 2001 From: nightpool Date: Mon, 31 May 2021 19:28:29 -0400 Subject: [PATCH 1/6] fix notification block --- Extensions/notificationblock.css | 9 +- Extensions/notificationblock.js | 350 +++++++++---------------------- Extensions/xkit_patches.js | 2 +- 3 files changed, 104 insertions(+), 257 deletions(-) diff --git a/Extensions/notificationblock.css b/Extensions/notificationblock.css index c51122894..3d4fe758a 100644 --- a/Extensions/notificationblock.css +++ b/Extensions/notificationblock.css @@ -1,5 +1,4 @@ .xkit-notification-notification-block-button { - position: absolute; right: 35px; top: 7px; background: rgba(255,255,255,.38) !important; @@ -11,16 +10,16 @@ text-decoration: none; text-transform: uppercase !important; line-height: 12px !important; height: 12px !important; +} - +[data-xkit-notificationblock-blocked] { + display: none; } .notification:hover .xkit-notification-notification-block-button { - display: block; - } .xkit-notification-notification-block-button:hover { background-color: rgba(255,255,255,.75) !important; -} \ No newline at end of file +} diff --git a/Extensions/notificationblock.js b/Extensions/notificationblock.js index 7ea931960..07f446f91 100644 --- a/Extensions/notificationblock.js +++ b/Extensions/notificationblock.js @@ -29,7 +29,7 @@ XKit.extensions.notificationblock = new Object({ }, - run: function() { + run: async function() { this.running = true; @@ -37,295 +37,153 @@ XKit.extensions.notificationblock = new Object({ return; } + await XKit.css_map.getCssMap(); XKit.tools.init_css("notificationblock"); - try { - var m_blacklist = XKit.storage.get("notificationblock", "posts", "").split(","); - if (m_blacklist !== "") { - this.blacklisted = m_blacklist; - } - } catch (e) { - XKit.storage.set("notificationblock", "posts", ""); - this.blacklisted = []; + var storage = XKit.storage.get_all("notificationblock"); + if (storage && storage.posts) { + this.blacklisted = storage.posts.value.split(","); } - if ($("#posts").length > 0 || $(".notification").length > 0 || $(".ui_note").length > 0) { - $(document).on('click', '.xnotificationblockbutton', XKit.extensions.notificationblock.on_click); - XKit.interface.create_control_button("xnotificationblockbutton", this.button_icon, "NotificationBlock", "", this.button_ok); - XKit.post_listener.add("notificationblock", XKit.extensions.notificationblock.do); - XKit.extensions.notificationblock.do(); - } + XKit.interface.react.create_control_button("xnotificationblockbutton", + this.button_icon, "NotificationBlock", + this.on_click.bind(this), this.button_ok + ); + + XKit.post_listener.add("notificationblock", this.do.bind(this)); + this.do(); if (XKit.interface.where().activity === true) { console.log("In activity, repeat block mode"); - setInterval(function() { XKit.extensions.notificationblock.do(); }, 1500); - } - - if (this.preferences.on_notifications.value === true) { - $(document).on("mouseenter", ".notification", XKit.extensions.notificationblock.enter_notification); - $(document).on("click", ".xkit-notification-notification-block-button", function(e) { - var m_parent = $(this).parentsUntil(".notification").parent(); - e.preventDefault(); - XKit.extensions.notificationblock.on_click_notification(m_parent, e); - }); + setInterval(this.do.bind(this), 1000); } }, - on_click_notification: function(obj, event) { - - var post_id = ""; - var post_url = ""; - - event.stopPropagation(); - event.stopImmediatePropagation(); - event.preventDefault(); - - if (typeof $(obj).attr('data-url-original') !== "undefined") { - post_url = $(obj).attr('data-url-original'); - } else { - post_url = $(obj).find(".preview_frame").attr('href'); - } - - if (post_url === "") { return; } - - post_url = post_url.split("/"); - for (var i = 0; i < post_url.length; i++) { - - if (post_url[i] === "post") { - post_id = post_url[i + 1]; - break; - } - - } - - if (XKit.extensions.notificationblock.preferences.ask.value === false) { - - XKit.extensions.notificationblock.block(post_id); - return; - - } - - XKit.window.show("Block notifications from this post?", "Notifications originating from this post will be blocked on the dashboard, Old Notifications and Activity page, without any indication that it was blocked.", "question", "
Block Notifications
Cancel
"); - - $("#xkit-notification-block-ok").click(function() { - - XKit.window.close(); - XKit.extensions.notificationblock.block(post_id); - - }); - - }, - - enter_notification: function(event) { - - var n_box = event.target; - if ($(n_box).hasClass("notification") === false || $(n_box).hasClass("notification_inner") === true) { - // Must be in a sub-div. - if ($(n_box).hasClass("notification_inner") === true) { - n_box = $(n_box).parent(); - } else { - n_box = $(n_box).parentsUntil(".notification").parent(); - } - } - - if (n_box.find(".xkit-notification-notification-block-button").length < 1) { - - // We are setting a timeout for the one-click reply button. - - setTimeout(function() { - - n_box.find(".xkit-notification-notification-block-button").remove(); - - var m_html = "block"; - - if ($(n_box).find(".block").length > 0) { - $(n_box).find(".block").after(m_html); - - if ($(n_box).find(".xkit-reply-button").length > 0) { - console.log("Has One-Click Reply button, pushing! 0"); - $(n_box).find(".xkit-notification-notification-block-button").css("right", (38 + $(n_box).find(".xkit-reply-button").width() + 5) + "px"); - } - - } else { - - $(n_box).find(".notification_sentence").append(m_html); - - if ($(n_box).find(".xkit-reply-button").length > 0) { - console.log("Has One-Click Reply button, pushing! 0"); - $(n_box).find(".xkit-notification-notification-block-button").css("right", (35 + $(n_box).find(".xkit-reply-button").width() + 5) + "px"); - } - - if ($(n_box).hasClass("xkit-old-notifications")) { - $(n_box).find(".xkit-notification-notification-block-button").css("top", "16px"); - } else { - $(n_box).find(".xkit-notification-notification-block-button").css("top", "12px"); - } - if ($(n_box).hasClass("stretchy_kid_container") === true) { - if ($(n_box).find(".xkit-reply-button").length > 0) { - console.log("Has One-Click Reply button, pushing! 1"); - $(n_box).find(".xkit-notification-notification-block-button").css("right", (8 + $(n_box).find(".xkit-reply-button").width() + 5) + "px"); - } else { - $(n_box).find(".xkit-notification-notification-block-button").css("right", "8px"); - } - } else { - if ($(n_box).hasClass("xkit-old-notifications")) { - - if ($(n_box).find(".xkit-reply-button").length > 0) { - console.log("Has One-Click Reply button, pushing! 2"); - $(n_box).find(".xkit-notification-notification-block-button").css("right", (43 + $(n_box).find(".xkit-reply-button").width() + 5) + "px"); - } else { - $(n_box).find(".xkit-notification-notification-block-button").css("right", "43px"); - } - } else { - if ($(n_box).find(".xkit-reply-button").length > 0) { - console.log("Has One-Click Reply button, pushing! 3"); - $(n_box).find(".xkit-notification-notification-block-button").css("right", (38 + $(n_box).find(".xkit-reply-button").width() + 5) + "px"); - } else { - $(n_box).find(".xkit-notification-notification-block-button").css("right", "38px"); - } - } - } - } - var m_right = 45 + $(n_box).find(".xkit-notification-notification-block-button").width(); - if ($(n_box).find(".xkit-reply-button").length > 0) { - console.log("Has One-Click Reply button, pushing! 15"); - m_right += $(n_box).find(".xkit-reply-button").width() + 8; - } - if (XKit.extensions.notificationblock.added_css !== true) { - XKit.tools.add_css(".notification .block, .notification .ignore { right: " + m_right + "px !important; }", "notificationblock_notfix"); - XKit.extensions.notificationblock.added_css = true; - } - - }, 400); - - } - + recheck_all: function() { + $(".notification.xnotificationblockchecked").removeClass("xnotificationblockchecked"); + this.do(); }, unblock: function(post_id) { - - var m_index = XKit.extensions.notificationblock.blacklisted.indexOf(post_id); + var m_index = this.blacklisted.indexOf(post_id); if (m_index !== -1) { - XKit.extensions.notificationblock.blacklisted.splice(m_index, 1); - XKit.storage.set("notificationblock", "posts", XKit.extensions.notificationblock.blacklisted.join(",")); + this.blacklisted.splice(m_index, 1); + XKit.storage.set("notificationblock", "posts", this.blacklisted.join(",")); } - $(".notification.xnotificationblockchecked").removeClass("xnotificationblockchecked"); - XKit.extensions.notificationblock.do(); + this.recheck_all(); }, block: function(post_id) { - - if (XKit.extensions.notificationblock.blacklisted.indexOf(post_id) === -1) { - XKit.extensions.notificationblock.blacklisted.push(post_id); - XKit.storage.set("notificationblock", "posts", XKit.extensions.notificationblock.blacklisted.join(",")); + if (this.blacklisted.indexOf(post_id) === -1) { + this.blacklisted.push(post_id); + XKit.storage.set("notificationblock", "posts", this.blacklisted.join(",")); } - $(".notification.xnotificationblockchecked").removeClass("xnotificationblockchecked"); - XKit.extensions.notificationblock.do(); + + this.recheck_all(); }, on_click: function(e) { - - var obj = e.target || e.srcElement; - - if (XKit.extensions.notificationblock.preferences.ask.value === false) { - - if ($(obj).hasClass("xkit-interface-completed")) { - XKit.extensions.notificationblock.unblock($(obj).attr('data-post-id')); - XKit.interface.completed_control_button($(obj), false); + const self = this; + const $block_button = $(e.target || e.srcElement); + const post_id = $block_button.attr('data-post-id'); + + if (this.preferences.ask.value === false) { + if ($block_button.hasClass("xkit-interface-completed")) { + this.unblock(post_id); + XKit.interface.completed_control_button($block_button, false); } else { - XKit.extensions.notificationblock.block($(obj).attr('data-post-id')); - XKit.interface.completed_control_button($(obj), true); + this.block(post_id); + XKit.interface.completed_control_button($block_button, true); } return; - } - if ($(obj).hasClass("xkit-interface-completed")) { - // Already blocked, user trying to unblock it. - - XKit.window.show("Unblock notifications from this post?", "Notifications from this post will be shown.
You'll need to refresh the page for changes to take effect.", "question", "
Unblock Notifications
Cancel
"); + if ($block_button.hasClass("xkit-interface-completed")) { + XKit.window.show("Unblock notifications from this post?", + "Notifications from this post will be shown.
You'll need to refresh the page for changes to take effect.", + "question", + '
Unblock Notifications
Cancel
'); $("#xkit-notification-block-ok").click(function() { - + self.unblock(post_id); XKit.window.close(); - XKit.extensions.notificationblock.unblock($(obj).attr('data-post-id')); - XKit.interface.completed_control_button($(obj), false); - + XKit.interface.completed_control_button($block_button, false); }); } else { - - XKit.window.show("Block notifications from this post?", "Notifications originating from this post will be blocked on the dashboard, Old Notifications and Activity page, without any indication that it was blocked.", "question", "
Block Notifications
Cancel
"); + XKit.window.show("Block notifications from this post?", + "Notifications originating from this post will be blocked on the dashboard, Old Notifications and Activity page, without any indication that it was blocked.", + "question", + '
Block Notifications
Cancel
'); $("#xkit-notification-block-ok").click(function() { - + self.block(post_id); XKit.window.close(); - XKit.extensions.notificationblock.block($(obj).attr('data-post-id')); - XKit.interface.completed_control_button($(obj), true); - + XKit.interface.completed_control_button($block_button, true); }); - } - }, - do: function() { + populate_notification_props: function() { + return XKit.tools.async_add_function(async () => { + /* globals tumblr */ - $(".notification").not(".xnotificationblockchecked").each(function() { + const keyStartsWith = (obj, prefix) => + Object.keys(obj).find(key => key.startsWith(prefix)); - $(this).addClass("xnotificationblockchecked"); + const cssMap = await tumblr.getCssMap(); + const elements = document.querySelectorAll( + cssMap.notification.map(cls => `.${cls}:not([data-target-id])`).join(',') + ); - var target_url = $(this).find(".notification_target").attr('href'); + elements.forEach(element => { + let fiber = element[keyStartsWith(element, '__reactInternalInstance')]; + const notificationProp = () => fiber.memoizedProps && fiber.memoizedProps.notification; - if ($(this).attr('data-url-original') !== "undefined" && $(this).attr('data-url-original') !== "") { - target_url = target_url + " " + $(this).attr('data-url-original'); - } - - if ($(this).find(".preview_frame").attr('href') !== "undefined") { - target_url = target_url + " " + $(this).find(".preview_frame").attr('href'); - } - - for (var i = 0; i < XKit.extensions.notificationblock.blacklisted.length; i++) { - if (XKit.extensions.notificationblock.blacklisted[i] === "" || - typeof(XKit.extensions.notificationblock.blacklisted[i]) === "undefined") { - continue; - } - if (target_url.indexOf("/post/" + XKit.extensions.notificationblock.blacklisted[i]) !== -1) { - console.log("Blocking notification because of post " + XKit.extensions.notificationblock.blacklisted[i]); - $(this).remove(); - return; + while (fiber && !notificationProp()) { + fiber = fiber.return; } - } + if (fiber) { + const {targetPostId} = notificationProp(); + element.dataset.targetId = targetPostId; + } + }); }); + }, + + do: async function() { + const self = this; + const blacklisted_post_regexp = new RegExp(`\\b(${self.blacklisted.join('|')})\\b`); + + await self.populate_notification_props(); - $(".ui_note,.activity-notification").not(".xnotificationblockchecked").each(function() { + $(`.notification, ${XKit.css_map.keyToCss('notification')}`). + not(".xnotificationblockchecked"). + each(function() { + const $note = $(this); - $(this).addClass("xnotificationblockchecked"); + $note.addClass("xnotificationblockchecked"); - var target_url = $(this).find(".part_glass,.activity-notification__glass").attr('href'); - target_url += " " + $(this).find(".ui_post_badge").attr("data-peepr"); + let target_url = $note.children('a').attr('href') || $note.find(".notification_target").attr('href'); - for (var i = 0; i < XKit.extensions.notificationblock.blacklisted.length; i++) { - if (XKit.extensions.notificationblock.blacklisted[i] === "" || - typeof(XKit.extensions.notificationblock.blacklisted[i]) === "undefined") { - continue; + if ($note.attr('data-target-id')) { + target_url = target_url + " " + $note.attr('data-target-id'); } - if (target_url.indexOf(XKit.extensions.notificationblock.blacklisted[i]) !== -1) { - console.log("Blocking notification because of post " + XKit.extensions.notificationblock.blacklisted[i]); - if ($(this).next().hasClass("xkit-activity-plus-condensed-opener")) { - $(this).next().remove(); - } - $(this).remove(); - return; + + if ($note.attr('data-url-original')) { + target_url = target_url + " " + $note.attr('data-url-original'); } - } - }); + if (blacklisted_post_regexp.test(target_url)) { + console.log(`Blocking ${target_url} with regex ${blacklisted_post_regexp}`); + this.dataset.xkitNotificationblockBlocked = true; + } + }); $(".xkit-old-notifications, .notification").first().addClass("first_notification"); $(".xkit-old-notifications, .notification").first().each(function() { @@ -334,30 +192,20 @@ XKit.extensions.notificationblock = new Object({ } }); - - if ($(".posts .post").length > 0) { - - var posts = XKit.interface.get_posts("xnotificationblockchecked"); - - $(posts).each(function() { - + if ($("[data-id]").length > 0) { + const posts = await XKit.interface.react.get_posts("xnotificationblockchecked", !!'can_edit'); + $(posts).each(async function() { $(this).addClass("xnotificationblockchecked"); + var post_id = this.dataset.postId; - var m_post = XKit.interface.post($(this)); - if (m_post.is_mine !== true) { return; } - - var this_id = m_post.id; - - XKit.interface.add_control_button(this, "xnotificationblockbutton", "data-root_id=\"" + this_id + "\""); - - if (XKit.extensions.notificationblock.blacklisted.indexOf(this_id) !== -1) { - - XKit.interface.completed_control_button($(this).find(".xnotificationblockbutton"), true); + await XKit.interface.react.add_control_button($(this), "xnotificationblockbutton"); + if (XKit.extensions.notificationblock.blacklisted.indexOf(post_id) !== -1) { + XKit.interface.completed_control_button( + $(this).find(".xnotificationblockbutton"), true + ); } - }); - } }, diff --git a/Extensions/xkit_patches.js b/Extensions/xkit_patches.js index fcf914ebf..e6a8b3a87 100644 --- a/Extensions/xkit_patches.js +++ b/Extensions/xkit_patches.js @@ -1025,7 +1025,7 @@ XKit.extensions.xkit_patches = new Object({ }`, `xkit_interface_icon__${class_name}`); if (typeof ok_icon !== "undefined") { - XKit.tools.add_css(`.${class_name} .xkit-interface-icon-completed { + XKit.tools.add_css(`.${class_name} .xkit-interface-completed { background-image: url('${ok_icon}'); }`, `xkit_interface_icon__completed__${class_name}`); } From 67516a1295aabc639b876a72fd2d588a000c935b Mon Sep 17 00:00:00 2001 From: nightpool Date: Mon, 31 May 2021 19:50:59 -0400 Subject: [PATCH 2/6] fix a few bugs --- Extensions/notificationblock.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Extensions/notificationblock.js b/Extensions/notificationblock.js index 07f446f91..e8c172fe2 100644 --- a/Extensions/notificationblock.js +++ b/Extensions/notificationblock.js @@ -61,7 +61,14 @@ XKit.extensions.notificationblock = new Object({ }, recheck_all: function() { - $(".notification.xnotificationblockchecked").removeClass("xnotificationblockchecked"); + const notificationClasses = [ + "notification", + ...XKit.css_map.keyToClasses('notification'), + ]; + + $(notificationClasses.map(cls => `.${cls}.xnotificationblockchecked`).join(", ")). + removeClass("xnotificationblockchecked"); + this.do(); }, @@ -196,13 +203,13 @@ XKit.extensions.notificationblock = new Object({ const posts = await XKit.interface.react.get_posts("xnotificationblockchecked", !!'can_edit'); $(posts).each(async function() { $(this).addClass("xnotificationblockchecked"); - var post_id = this.dataset.postId; + var post_id = this.dataset.id; await XKit.interface.react.add_control_button($(this), "xnotificationblockbutton"); if (XKit.extensions.notificationblock.blacklisted.indexOf(post_id) !== -1) { XKit.interface.completed_control_button( - $(this).find(".xnotificationblockbutton"), true + $(this).find(".xnotificationblockbutton div"), true ); } }); From e849af4b7d26e938974e16915e1b4af6c4890051 Mon Sep 17 00:00:00 2001 From: nightpool Date: Mon, 31 May 2021 20:29:50 -0400 Subject: [PATCH 3/6] fix unhiding previously blocked notifications --- Extensions/notificationblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extensions/notificationblock.js b/Extensions/notificationblock.js index e8c172fe2..80fdc875d 100644 --- a/Extensions/notificationblock.js +++ b/Extensions/notificationblock.js @@ -67,7 +67,7 @@ XKit.extensions.notificationblock = new Object({ ]; $(notificationClasses.map(cls => `.${cls}.xnotificationblockchecked`).join(", ")). - removeClass("xnotificationblockchecked"); + removeClass("xnotificationblockchecked").removeAttr('data-xkit-notificationblock-blocked'); this.do(); }, From 0fcc64bd805a565a77309e1dadf0785fa5e47dfb Mon Sep 17 00:00:00 2001 From: nightpool Date: Mon, 31 May 2021 20:34:17 -0400 Subject: [PATCH 4/6] Update copy, bunp versions --- Extensions/notificationblock.js | 12 +++--------- Extensions/xkit_patches.js | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Extensions/notificationblock.js b/Extensions/notificationblock.js index 80fdc875d..6d4326b0e 100644 --- a/Extensions/notificationblock.js +++ b/Extensions/notificationblock.js @@ -1,5 +1,5 @@ //* TITLE NotificationBlock **// -//* VERSION 1.3.5 **// +//* VERSION 1.4.0 **// //* DESCRIPTION Blocks notifications from a post **// //* DEVELOPER new-xkit **// //* DETAILS One post got way too popular and now just annoying you? Click on the notification block icon on that post to hide the notifications from that post. If you have Go-To-Dash installed, you can click on a notification, then click View button on top-right corner to quickly go back to the post on your dashboard. **// @@ -21,12 +21,6 @@ XKit.extensions.notificationblock = new Object({ value: true }, - on_notifications: { - text: "Show the NotificationBlock button ('block') on notifications", - default: true, - value: true - } - }, run: async function() { @@ -111,7 +105,7 @@ XKit.extensions.notificationblock = new Object({ if ($block_button.hasClass("xkit-interface-completed")) { XKit.window.show("Unblock notifications from this post?", - "Notifications from this post will be shown.
You'll need to refresh the page for changes to take effect.", + "Notifications from this post will be shown. You may have to refresh the page for changes to take effect", "question", '
Unblock Notifications
Cancel
'); @@ -123,7 +117,7 @@ XKit.extensions.notificationblock = new Object({ } else { XKit.window.show("Block notifications from this post?", - "Notifications originating from this post will be blocked on the dashboard, Old Notifications and Activity page, without any indication that it was blocked.", + "Notifications originating from this post will be blocked on the dashboard and activity page, without any indication that they were blocked.", "question", '
Block Notifications
Cancel
'); diff --git a/Extensions/xkit_patches.js b/Extensions/xkit_patches.js index e6a8b3a87..6b8ee17c1 100644 --- a/Extensions/xkit_patches.js +++ b/Extensions/xkit_patches.js @@ -1,5 +1,5 @@ //* TITLE XKit Patches **// -//* VERSION 7.4.13 **// +//* VERSION 7.4.14 **// //* DESCRIPTION Patches framework **// //* DEVELOPER new-xkit **// From 75fe0ee3a56ab69ca2ae36f2e8fc7f6c5188f55c Mon Sep 17 00:00:00 2001 From: nightpool Date: Mon, 31 May 2021 20:52:21 -0400 Subject: [PATCH 5/6] fix empty regexp matching everything --- Extensions/notificationblock.js | 43 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Extensions/notificationblock.js b/Extensions/notificationblock.js index 6d4326b0e..4e8b92157 100644 --- a/Extensions/notificationblock.js +++ b/Extensions/notificationblock.js @@ -36,7 +36,7 @@ XKit.extensions.notificationblock = new Object({ var storage = XKit.storage.get_all("notificationblock"); if (storage && storage.posts) { - this.blacklisted = storage.posts.value.split(","); + this.blacklisted = storage.posts.value.split(",").filter(i => i); } XKit.interface.react.create_control_button("xnotificationblockbutton", @@ -159,32 +159,35 @@ XKit.extensions.notificationblock = new Object({ do: async function() { const self = this; - const blacklisted_post_regexp = new RegExp(`\\b(${self.blacklisted.join('|')})\\b`); - await self.populate_notification_props(); + if (self.blacklisted.some(i => i)) { + const blacklisted_post_regexp = new RegExp(`\\b(${self.blacklisted.join('|')})\\b`); - $(`.notification, ${XKit.css_map.keyToCss('notification')}`). - not(".xnotificationblockchecked"). - each(function() { - const $note = $(this); + await self.populate_notification_props(); - $note.addClass("xnotificationblockchecked"); + $(`.notification, ${XKit.css_map.keyToCss('notification')}`). + not(".xnotificationblockchecked"). + each(function() { + const $note = $(this); - let target_url = $note.children('a').attr('href') || $note.find(".notification_target").attr('href'); + $note.addClass("xnotificationblockchecked"); - if ($note.attr('data-target-id')) { - target_url = target_url + " " + $note.attr('data-target-id'); - } + let target_url = $note.children('a').attr('href') || $note.find(".notification_target").attr('href'); - if ($note.attr('data-url-original')) { - target_url = target_url + " " + $note.attr('data-url-original'); - } + if ($note.attr('data-target-id')) { + target_url = target_url + " " + $note.attr('data-target-id'); + } - if (blacklisted_post_regexp.test(target_url)) { - console.log(`Blocking ${target_url} with regex ${blacklisted_post_regexp}`); - this.dataset.xkitNotificationblockBlocked = true; - } - }); + if ($note.attr('data-url-original')) { + target_url = target_url + " " + $note.attr('data-url-original'); + } + + if (blacklisted_post_regexp.test(target_url)) { + console.log(`Blocking ${target_url} with regex ${blacklisted_post_regexp}`); + this.dataset.xkitNotificationblockBlocked = true; + } + }); + } $(".xkit-old-notifications, .notification").first().addClass("first_notification"); $(".xkit-old-notifications, .notification").first().each(function() { From 2263a29f876751921ed22e5031489dec8373a467 Mon Sep 17 00:00:00 2001 From: nightpool Date: Tue, 1 Jun 2021 00:00:57 -0400 Subject: [PATCH 6/6] to the eslint-joker, this is normal indentation. --- Extensions/notificationblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extensions/notificationblock.js b/Extensions/notificationblock.js index 4e8b92157..3af06d8a8 100644 --- a/Extensions/notificationblock.js +++ b/Extensions/notificationblock.js @@ -69,7 +69,7 @@ XKit.extensions.notificationblock = new Object({ unblock: function(post_id) { var m_index = this.blacklisted.indexOf(post_id); if (m_index !== -1) { - this.blacklisted.splice(m_index, 1); + this.blacklisted.splice(m_index, 1); XKit.storage.set("notificationblock", "posts", this.blacklisted.join(",")); }