Add USw hook to remove get stylus button (#1239)
This commit is contained in:
parent
d736a00bc1
commit
440a9f4763
|
@ -66,6 +66,21 @@ bgReady.all.then(() => {
|
|||
{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
|
||||
*/
|
||||
|
|
22
content/install-hook-userstylesworld.js
Normal file
22
content/install-hook-userstylesworld.js
Normal 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);
|
||||
})();
|
Loading…
Reference in New Issue
Block a user