Switch to more flexible messaging

This commit is contained in:
Gusted 2021-04-30 15:08:39 +02:00
parent e428b1e58c
commit 793f14c587
No known key found for this signature in database
GPG Key ID: FD821B732837125F
2 changed files with 9 additions and 3 deletions

View File

@ -78,7 +78,7 @@ bgReady.all.then(() => {
});
}, {
url: [
{hostEquals: 'userstyles.world', urlMatches: '/style/\\d+[^/]*/[a-z-0-9]+$'},
{hostEquals: 'userstyles.world'},
],
});
/*

View File

@ -3,12 +3,18 @@
(() => {
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-remove-stylus-button'
&& event.data.type === 'usw-ready'
&& allowedOrigin === event.origin
) {
document.querySelector('a#stylus').remove();
sendPostMessage({type: 'usw-remove-stylus-button'});
}
};