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