diff --git a/Extensions/postblock.css b/Extensions/postblock.css index 5fb39480d..9265996bf 100644 --- a/Extensions/postblock.css +++ b/Extensions/postblock.css @@ -6,3 +6,16 @@ color: rgb(128,128,128); font-size: small; } + +.xkit-postblock-cp-migration { + border-bottom: 1px solid var(--xkit-border); + + padding: 0 1em; + font-size: 14px; + line-height: 1.5; + color: rgb(80,80,80); +} + +.xkit-postblock-cp-migration button { + margin: 0 0 .75em 0; +} diff --git a/Extensions/postblock.js b/Extensions/postblock.js index 301fb66f1..7f6e25e26 100644 --- a/Extensions/postblock.js +++ b/Extensions/postblock.js @@ -1,5 +1,5 @@ //* TITLE PostBlock **// -//* VERSION 1.0.2 **// +//* VERSION 1.0.3 **// //* DESCRIPTION Block the posts you don't like **// //* DETAILS This extension lets you blocks posts you don't like on your dashboard. When you block a post, it will be hidden completely, including reblogs of it.

Tip: hold down ALT to skip the blocking confirmation! **// //* DEVELOPER new-xkit **// @@ -131,6 +131,59 @@ XKit.extensions.postblock = new Object({ }); + XKit.extensions.postblock.migrationCpanel(m_div); + }, + + migrationCpanel: function(m_div) { + + $('.xkit-postblock-cp-migration').remove(); + $(m_div).prepend(` +
+

+ The XKit Rewritten extension includes a version of this script. + To migrate easily, install XKit Rewritten and enable its PostBlock feature in your browser toolbar, then refresh this page and press this button to copy your blocked posts: +

+ +
+ `); + + const toCopy = XKit.extensions.postblock.blacklisted.filter(Boolean); + + $('#xkit-postblock-cp-export').on('click', async function() { + if (!toCopy.length) { + XKit.window.show( + 'Nothing to Copy', + "You don't have any blocked posts to copy!", + 'error', + '
OK
', + ); + return; + } + + this.setAttribute('disabled', ''); + this.classList.add('disabled'); + + let succeeded = false; + + window.addEventListener('xkit-postblock-migration-success', () => { succeeded = true; }, { once: true }); + window.dispatchEvent(new CustomEvent('xkit-postblock-migration', { detail: JSON.stringify(toCopy) })); + + setTimeout(() => { + this.removeAttribute('disabled'); + this.classList.remove('disabled'); + + if (succeeded) { + XKit.extensions.xkit_preferences.close(); + } else { + XKit.window.show( + 'Failure', + 'Make sure you have installed XKit Rewritten [VERSION NUMBER GOES HERE] or later, have refreshed the page, and have enabled PostBlock.', + 'error', + '
OK
', + ); + } + }, 500); + }); }, destroy: function() {