Switch to more flexible messaging
This commit is contained in:
parent
e428b1e58c
commit
793f14c587
|
@ -78,7 +78,7 @@ bgReady.all.then(() => {
|
|||
});
|
||||
}, {
|
||||
url: [
|
||||
{hostEquals: 'userstyles.world', urlMatches: '/style/\\d+[^/]*/[a-z-0-9]+$'},
|
||||
{hostEquals: 'userstyles.world'},
|
||||
],
|
||||
});
|
||||
/*
|
||||
|
|
|
@ -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'});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user