From 62791cda820a4a00aca1368201dc213b9e0744ad Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 8 Jun 2021 18:32:01 +0200 Subject: [PATCH] Wait for `usw-ready`before sending style --- content/install-hook-userstylesworld.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/content/install-hook-userstylesworld.js b/content/install-hook-userstylesworld.js index 7a4bb19a..6a7ae5a6 100644 --- a/content/install-hook-userstylesworld.js +++ b/content/install-hook-userstylesworld.js @@ -16,14 +16,15 @@ && allowedOrigin === event.origin ) { sendPostMessage({type: 'usw-remove-stylus-button'}); + + if (window.location.pathname === '/api/oauth/authorize_style/new') { + API.styles.find({_linking: true}).then(style => { + console.log(style); + sendPostMessage({type: 'usw-fill-new-style', data: style}); + }); + } } }; - if (window.location.pathname === '/api/oauth/authorize_style/new') { - API.styles.find({_linking: true}).then(style => { - sendPostMessage({type: 'usw-fill-new-style', data: style}); - }); - } - window.addEventListener('message', onPageLoaded); })();