From 5d359827dab80982cf86e1edb61b841aa1947e6b Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 20 Jul 2021 15:42:05 +0300 Subject: [PATCH] use URLSearchParams --- content/install-hook-userstylesworld.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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}); });