diff --git a/background/style-manager.js b/background/style-manager.js
index d8867387..6df2e9cf 100644
--- a/background/style-manager.js
+++ b/background/style-manager.js
@@ -6,6 +6,7 @@
/* global prefs */
/* global tabMan */
/* global usercssMan */
+/* global tokenMan */
'use strict';
/*
@@ -54,6 +55,9 @@ const styleMan = (() => {
chrome.runtime.onConnect.addListener(handleLivePreview);
+ chrome.runtime.onConnect.addListener(handleLinkingUSW);
+
+
//#endregion
//#region Exports
@@ -345,6 +349,19 @@ const styleMan = (() => {
});
}
+ function handleLinkingUSW(port) {
+ if (port.name !== 'link-style-usw') {
+ return;
+ }
+ port.onMessage.addListener(async style => {
+ if (!style.id) {
+ return;
+ }
+ const result = await tokenMan.getToken('userstylesworld', true);
+ console.log(result);
+ });
+ }
+
async function addIncludeExclude(type, id, rule) {
if (ready.then) await ready;
const style = Object.assign({}, id2style(id));
diff --git a/background/token-manager.js b/background/token-manager.js
index 67cefe51..f1e4f550 100644
--- a/background/token-manager.js
+++ b/background/token-manager.js
@@ -1,4 +1,4 @@
-/* global FIREFOX getActiveTab waitForTabUrl */// toolbox.js
+/* global FIREFOX getActiveTab waitForTabUrl URLS */// toolbox.js
/* global chromeLocal */// storage-util.js
'use strict';
@@ -48,6 +48,14 @@ const tokenMan = (() => {
'https://' + location.hostname + '.chromiumapp.org/',
scopes: ['Files.ReadWrite.AppFolder', 'offline_access'],
},
+ userstylesworld: {
+ flow: 'code',
+ clientId: 'publicccc_client',
+ clientSecret: 'secreettUwU', // Don't judege.
+ authURL: URLS.usw + 'api/oauth/authorize_style',
+ tokenURL: URLS.usw + 'api/oauth/access_token',
+ redirect_uri: 'https://gusted.xyz/callback_helper/',
+ },
};
const NETWORK_LATENCY = 30; // seconds
@@ -177,6 +185,7 @@ const tokenMan = (() => {
grant_type: 'authorization_code',
client_id: provider.clientId,
redirect_uri: query.redirect_uri,
+ state,
};
if (provider.clientSecret) {
body.client_secret = provider.clientSecret;
diff --git a/edit.html b/edit.html
index cd6bac6d..377db734 100644
--- a/edit.html
+++ b/edit.html
@@ -395,6 +395,9 @@