use URLSearchParams

This commit is contained in:
tophf 2021-07-20 15:42:05 +03:00 committed by GitHub
parent ede20ca30c
commit 5d359827da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,12 +18,8 @@
sendPostMessage({type: 'usw-remove-stylus-button'}); sendPostMessage({type: 'usw-remove-stylus-button'});
if (location.pathname === '/api/oauth/style/new') { if (location.pathname === '/api/oauth/style/new') {
// Gets the search query string, and get the vendor_data from it. const styleId = Number(new URLSearchParams(location.search).get('vendor_data'));
// Which is the id of the style that shall be linked with. API.styles.get(styleId).then(style => {
const vendorData = window.location.search.split('&')
.find(query => query.startsWith('vendor_data'))
.split('=')[1];
API.styles.get(Number(vendorData)).then(style => {
style.sourceCode = style.tmpSourceCode; style.sourceCode = style.tmpSourceCode;
sendPostMessage({type: 'usw-fill-new-style', data: style}); sendPostMessage({type: 'usw-fill-new-style', data: style});
}); });