Add USw hook to remove get stylus button (#1239)

This commit is contained in:
Gusted 2021-04-30 13:39:07 +00:00 committed by GitHub
parent d736a00bc1
commit 440a9f4763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View File

@ -66,6 +66,21 @@ bgReady.all.then(() => {
{hostEquals: 'sleazyfork.org', urlMatches}, {hostEquals: 'sleazyfork.org', urlMatches},
], ],
}); });
/*
* Removes the Get Stylus button on style pages.
* Not using manifest.json as adding a content script disables the extension on update.
*/
chrome.webNavigation.onCommitted.addListener(({tabId}) => {
chrome.tabs.executeScript(tabId, {
file: '/content/install-hook-userstylesworld.js',
runAt: 'document_start',
});
}, {
url: [
{hostEquals: 'userstyles.world'},
],
});
/* /*
* FF misses some about:blank iframes so we inject our content script explicitly * FF misses some about:blank iframes so we inject our content script explicitly
*/ */

View File

@ -0,0 +1,22 @@
'use strict';
(() => {
const allowedOrigin = 'https://userstyles.world';
const sendPostMessage = message => {
if (allowedOrigin === location.origin) {
window.postMessage(message, location.origin);
}
};
const onPageLoaded = event => {
if (event.data
&& event.data.type === 'usw-ready'
&& allowedOrigin === event.origin
) {
sendPostMessage({type: 'usw-remove-stylus-button'});
}
};
window.addEventListener('message', onPageLoaded);
})();