Send requested info (#1294)
This commit is contained in:
parent
6e591b0d52
commit
e1b65ae21f
|
@ -12,9 +12,10 @@
|
|||
|
||||
const onPageLoaded = event => {
|
||||
if (event.data
|
||||
&& event.data.type === 'usw-ready'
|
||||
&& allowedOrigin === event.origin
|
||||
) {
|
||||
switch (event.data.type) {
|
||||
case 'usw-ready': {
|
||||
sendPostMessage({type: 'usw-remove-stylus-button'});
|
||||
|
||||
if (location.pathname === '/api/oauth/style/new') {
|
||||
|
@ -23,6 +24,24 @@
|
|||
sendPostMessage({type: 'usw-fill-new-style', data});
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'usw-style-info-request': {
|
||||
switch (event.data.requestType) {
|
||||
case 'installed': {
|
||||
API.styles.find({updateUrl: `https://userstyles.world/api/style/${event.data.styleID}.user.css`})
|
||||
.then(style => {
|
||||
sendPostMessage({
|
||||
type: 'usw-style-info-response',
|
||||
data: {installed: Boolean(style), requestType: 'installed'},
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user