2021-06-29 09:36:59 +00:00
|
|
|
/* global API */// msg.js
|
2021-04-30 13:39:07 +00:00
|
|
|
'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'});
|
2021-06-29 09:36:59 +00:00
|
|
|
|
2021-07-02 00:12:24 +00:00
|
|
|
if (location.pathname === '/api/oauth/style/new') {
|
2021-07-20 12:56:45 +00:00
|
|
|
const styleId = Number(new URLSearchParams(location.search).get('vendor_data'));
|
2021-07-30 12:44:06 +00:00
|
|
|
API.data.pop('usw' + styleId).then(data => {
|
|
|
|
sendPostMessage({type: 'usw-fill-new-style', data});
|
2021-06-29 09:36:59 +00:00
|
|
|
});
|
|
|
|
}
|
2021-04-30 13:39:07 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener('message', onPageLoaded);
|
|
|
|
})();
|