diff --git a/.eslintrc.js b/.eslintrc.js index 5a2875d..a198a89 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,8 +17,14 @@ module.exports = { "space-in-parens": ["error", "never"], "object-curly-spacing": ["error", "never"], "array-bracket-spacing": ["error", "never"], - "comma-spacing": ["error", {before: false, after: true}], - "arrow-spacing": ["error", {before: true, after: true}], + "comma-spacing": ["error", { + before: false, + after: true + }], + "arrow-spacing": ["error", { + before: true, + after: true + }], "space-before-blocks": ["error", "always"], "spaced-comment": ["error", "always"], "block-spacing": ["error", "never"], @@ -43,11 +49,21 @@ module.exports = { ], "no-multiple-empty-lines": [ "error", - {max: 1, maxBOF: 0, maxEOF: 0}, + { + max: 1, + maxBOF: 0, + maxEOF: 0 + }, ], - "space-unary-ops": ["error", {words: true, nonwords: false}], + "space-unary-ops": ["error", { + words: true, + nonwords: false + }], "space-infix-ops": "error", - "key-spacing": ["error", {beforeColon: false, afterColon: true}], + "key-spacing": ["error", { + beforeColon: false, + afterColon: true + }], "comma-style": ["error", "last"], "comma-dangle": [ "error", diff --git a/.releaserc.json b/.releaserc.json index 1e84c4a..fb52120 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,10 +1,10 @@ { - "debug": true, - "branches": "master", - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/npm", - "@semantic-release/github" - ] -} \ No newline at end of file + "debug": true, + "branches": "master", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/npm", + "@semantic-release/github" + ] +} diff --git a/manifest.json b/manifest.json index 7009fcb..4431d62 100644 --- a/manifest.json +++ b/manifest.json @@ -1,40 +1,43 @@ { - "name": "Casdoor", - "description": "The Casdoor extension can help browser users automatically log into applications protected by Casdoor single-sign-on (SSO) system.", - "version": "1.0.0", - "manifest_version": 3, - "permissions": ["storage", "identity"], - "action": { - "default_popup": "/src/popup.html", - "default_icon": { - "16": "/images/icon16.png", - "32": "/images/icon32.png", - "48": "/images/icon48.png", - "128": "/images/icon128.png" - } - }, - "icons": { - "16": "/images/icon16.png", - "32": "/images/icon32.png", - "48": "/images/icon48.png", - "128": "/images/icon128.png" - }, - "content_scripts": [ - { - "matches": [ - "https://*/*", - "http://*/*" - ], - "js": [ - "/src/content-script.js", - "/src/sdk.js", - "/src/oauth.js", - "/src/config.js" - ] - } - ], - "host_permissions": [ + "name": "Casdoor", + "description": "The Casdoor extension can help browser users automatically log into applications protected by Casdoor single-sign-on (SSO) system.", + "version": "1.0.0", + "manifest_version": 3, + "permissions": [ + "storage", + "identity" + ], + "action": { + "default_popup": "/src/popup.html", + "default_icon": { + "16": "/images/icon16.png", + "32": "/images/icon32.png", + "48": "/images/icon48.png", + "128": "/images/icon128.png" + } + }, + "icons": { + "16": "/images/icon16.png", + "32": "/images/icon32.png", + "48": "/images/icon48.png", + "128": "/images/icon128.png" + }, + "content_scripts": [ + { + "matches": [ "https://*/*", "http://*/*" - ] + ], + "js": [ + "/src/content-script.js", + "/src/sdk.js", + "/src/oauth.js", + "/src/config.js" + ] + } + ], + "host_permissions": [ + "https://*/*", + "http://*/*" + ] } diff --git a/src/oauth.js b/src/oauth.js index 111700e..9a5ddee 100644 --- a/src/oauth.js +++ b/src/oauth.js @@ -40,7 +40,7 @@ function login() { .getUserProfile(accessToken) .then((userProfile) => displayUserProfile(userProfile)); }); - setInputDisabledState(true, "endpoint", "applicationName") + setInputDisabledState(true, "endpoint", "applicationName"); } else { alert("Login failed!"); } @@ -50,7 +50,7 @@ function login() { // eslint-disable-next-line no-unused-vars function logout() { chrome.storage.sync.set({accessToken: ""}, () => clearUserProfile()); - setInputDisabledState(false, "endpoint", "applicationName") + setInputDisabledState(false, "endpoint", "applicationName"); } function displayUserProfile(userProfile) { @@ -66,13 +66,13 @@ function clearUserProfile() { document.getElementById("loginOrLogout").innerText = "Login"; } -function setInputDisabledState(disabledState, ...elementIds) { - elementIds.forEach(elementId => { - const inputElement = document.getElementById(elementId); - if (inputElement) { - inputElement.disabled = disabledState; - } else { - console.warn(`No element found with ID: ${elementId}`); - } - }); +function setInputDisabledState(disabledState, ...elementIds) { + elementIds.forEach(elementId => { + const inputElement = document.getElementById(elementId); + if (inputElement) { + inputElement.disabled = disabledState; + } else { + console.warn(`No element found with ID: ${elementId}`); + } + }); } diff --git a/src/popup.html b/src/popup.html index 517182e..bfe0f7f 100644 --- a/src/popup.html +++ b/src/popup.html @@ -1,34 +1,34 @@ - + - - -
-

Casdoor

-
-
- endpoint: - -
-
- applicationName: - -
-
- Enable auto login: - -
-
- -
+ + +
+

Casdoor

+
+
+ endpoint: +
- - - - - +
+ applicationName: + +
+
+ Enable auto login: + +
+
+ +
+
+ + + + + diff --git a/src/popup.js b/src/popup.js index a1ad9fe..b7f6d7d 100644 --- a/src/popup.js +++ b/src/popup.js @@ -40,7 +40,7 @@ document.addEventListener("DOMContentLoaded", function() { const managedAccounts = account.data.managedAccounts; chrome.storage.sync.set({managedAccounts}); }); - setInputDisabledState(true, "endpoint", "applicationName") + setInputDisabledState(true, "endpoint", "applicationName"); } else { clearUserProfile(); } diff --git a/src/sdk.js b/src/sdk.js index fdbb644..bd851f0 100644 --- a/src/sdk.js +++ b/src/sdk.js @@ -13,6 +13,7 @@ // limitations under the License. /* eslint-disable no-undef */ + // eslint-disable-next-line no-unused-vars class Sdk { constructor(config) { @@ -38,8 +39,8 @@ class Sdk { getAccessTokenFromRedirectUrl(redirectUrl) { if (redirectUrl) { - const accessTokenMatch = redirectUrl.match(/#access_token=([^&]*)/); - const accessToken = accessTokenMatch ? accessTokenMatch[1] : ""; + const accessTokenMatch = redirectUrl.match(/#access_token=([^&]*)/); + const accessToken = accessTokenMatch ? accessTokenMatch[1] : ""; return accessToken; } return "";