├── .github ├── FUNDING.yml ├── assets │ ├── logo-red.png │ ├── logo-green.png │ ├── logo-yellow.png │ └── qr-code-firefox.json ├── ISSUE_TEMPLATE │ ├── config.yml │ └── 0-bug.yaml └── workflows │ ├── draft.yaml │ ├── test.yaml │ ├── build.yaml │ └── lint.yaml ├── src ├── images │ ├── logo16.png │ ├── logo32.png │ ├── logo48.png │ ├── logo96.png │ ├── logo128.png │ ├── logo-red16.png │ ├── logo-red32.png │ ├── logo-red48.png │ ├── logo-yellow16.png │ ├── logo-yellow32.png │ └── logo-yellow48.png ├── css │ ├── popup.css │ ├── options.css │ ├── main.css │ └── auth.css ├── js │ ├── panel.js │ ├── permissions.js │ ├── main.js │ ├── content-script.js │ ├── theme.js │ ├── popup.js │ ├── auth.js │ ├── export.js │ ├── service-worker.js │ └── options.js └── html │ ├── panel.html │ ├── permissions.html │ ├── auth.html │ ├── popup.html │ └── options.html ├── .prettierignore ├── PRIVACY.md ├── tests ├── secrets.txt └── test.js ├── manifest-chrome.json ├── .gitignore ├── manifest-firefox.json ├── .eslintrc.json ├── .prettierrc.json ├── eslint.config.mjs ├── gulpfile.js ├── package.json ├── manifest.json ├── README.md └── LICENSE /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: cssnr 2 | -------------------------------------------------------------------------------- /src/images/logo16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo16.png -------------------------------------------------------------------------------- /src/images/logo32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo32.png -------------------------------------------------------------------------------- /src/images/logo48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo48.png -------------------------------------------------------------------------------- /src/images/logo96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo96.png -------------------------------------------------------------------------------- /src/images/logo128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo128.png -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | dist/ 4 | node_modules/ 5 | package-lock.json 6 | *.html 7 | -------------------------------------------------------------------------------- /src/images/logo-red16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo-red16.png -------------------------------------------------------------------------------- /src/images/logo-red32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo-red32.png -------------------------------------------------------------------------------- /src/images/logo-red48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo-red48.png -------------------------------------------------------------------------------- /.github/assets/logo-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/.github/assets/logo-red.png -------------------------------------------------------------------------------- /PRIVACY.md: -------------------------------------------------------------------------------- 1 | # Data Collection 2 | 3 | Your data is not being collected, stored or used for any purpose. 4 | -------------------------------------------------------------------------------- /src/images/logo-yellow16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo-yellow16.png -------------------------------------------------------------------------------- /src/images/logo-yellow32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo-yellow32.png -------------------------------------------------------------------------------- /src/images/logo-yellow48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/src/images/logo-yellow48.png -------------------------------------------------------------------------------- /.github/assets/logo-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/.github/assets/logo-green.png -------------------------------------------------------------------------------- /.github/assets/logo-yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cssnr/auto-auth/HEAD/.github/assets/logo-yellow.png -------------------------------------------------------------------------------- /tests/secrets.txt: -------------------------------------------------------------------------------- 1 | { 2 | "authenticationtest.com": "user:pass", 3 | "cssnr.com": "guest:guest", 4 | "httpbin.org": "guest:guest" 5 | } 6 | -------------------------------------------------------------------------------- /manifest-chrome.json: -------------------------------------------------------------------------------- 1 | { 2 | "background": { 3 | "service_worker": "js/service-worker.js" 4 | }, 5 | "minimum_chrome_version": "120" 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | .vscode/ 4 | **/dist/ 5 | build/ 6 | node_modules/ 7 | web-ext-artifacts/ 8 | tests/screenshots/ 9 | src/manifest.json 10 | -------------------------------------------------------------------------------- /src/css/popup.css: -------------------------------------------------------------------------------- 1 | /* CSS for popup.html */ 2 | 3 | body { 4 | min-width: 340px; 5 | width: 100%; 6 | max-width: 100vw; 7 | overflow-x: hidden; 8 | } 9 | -------------------------------------------------------------------------------- /src/css/options.css: -------------------------------------------------------------------------------- 1 | /* CSS for options.html */ 2 | 3 | body { 4 | min-width: 340px; 5 | width: 100%; 6 | max-width: 100vw; 7 | } 8 | 9 | .card { 10 | max-width: 900px; 11 | } 12 | -------------------------------------------------------------------------------- /manifest-firefox.json: -------------------------------------------------------------------------------- 1 | { 2 | "background": { 3 | "scripts": ["js/service-worker.js"] 4 | }, 5 | "browser_specific_settings": { 6 | "gecko": { 7 | "id": "auto-auth@cssnr.com", 8 | "strict_min_version": "128.0" 9 | }, 10 | "gecko_android ": { 11 | "strict_min_version": "128.0" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "jquery": true, 6 | "webextensions": true 7 | }, 8 | "extends": "eslint:recommended", 9 | "parserOptions": { 10 | "ecmaVersion": "latest", 11 | "sourceType": "module" 12 | }, 13 | "rules": { 14 | "no-undef": "off", 15 | "no-extra-semi": "off" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "tabWidth": 4, 4 | "semi": false, 5 | "singleQuote": true, 6 | "overrides": [ 7 | { 8 | "files": ["**/*.html", "**/*.yaml", "**/*.yml"], 9 | "options": { 10 | "singleQuote": false 11 | } 12 | }, 13 | { 14 | "files": ["**/*.json", "**/*.yaml", "**/*.yml"], 15 | "options": { 16 | "tabWidth": 2 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/css/main.css: -------------------------------------------------------------------------------- 1 | /* Common CSS for Extension Pages */ 2 | 3 | svg { 4 | height: 1em; 5 | width: 1em; 6 | margin-bottom: 0.15em; 7 | } 8 | 9 | #toast-container { 10 | z-index: 3; 11 | } 12 | 13 | #back-to-top { 14 | position: fixed; 15 | bottom: 64px; 16 | right: 20px; 17 | display: none; 18 | z-index: 3; 19 | } 20 | 21 | .text-ellipsis { 22 | max-width: 100%; 23 | overflow: hidden; 24 | white-space: nowrap; 25 | text-overflow: ellipsis; 26 | display: inline-block; 27 | } 28 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | 3 | export default [ 4 | js.configs.recommended, 5 | { 6 | languageOptions: { 7 | ecmaVersion: 'latest', 8 | sourceType: 'module', 9 | }, 10 | settings: { 11 | env: { 12 | browser: true, 13 | es2021: true, 14 | jquery: true, 15 | webextensions: true, 16 | }, 17 | }, 18 | rules: { 19 | 'no-undef': 'off', 20 | 'no-extra-semi': 'off', 21 | }, 22 | }, 23 | ] 24 | -------------------------------------------------------------------------------- /src/js/panel.js: -------------------------------------------------------------------------------- 1 | // JS for panel.html 2 | 3 | document.addEventListener('DOMContentLoaded', domContentLoaded) 4 | document.getElementById('close').addEventListener('click', closePanel) 5 | 6 | /** 7 | * DOMContentLoaded 8 | * @function domContentLoaded 9 | */ 10 | async function domContentLoaded() { 11 | console.debug('domContentLoaded') 12 | const { options } = await chrome.storage.sync.get(['options']) 13 | console.debug('options:', options) 14 | } 15 | 16 | function closePanel(event) { 17 | console.debug('closePanel:', event) 18 | event.preventDefault() 19 | window.close() 20 | } 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: "💡 Request a Feature" 4 | about: Request a New Feature or Enhancement in the Discussions. 5 | url: https://github.com/cssnr/auto-auth/discussions/new?category=feature-requests 6 | 7 | - name: "❔ Ask a Question" 8 | about: Ask a General Question or start a Discussions. 9 | url: https://github.com/cssnr/auto-auth/discussions/new?category=q-a 10 | 11 | - name: "💬 Join Discord" 12 | about: Chat with us about Issues, Features, Questions and More. 13 | url: https://discord.gg/wXy6m2X8wY 14 | 15 | - name: "📝 Submit Feedback" 16 | about: Send General Feedback. 17 | url: https://cssnr.github.io/feedback/?app=Auto%20Auth 18 | -------------------------------------------------------------------------------- /.github/workflows/draft.yaml: -------------------------------------------------------------------------------- 1 | name: "Draft Release" 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: ["master"] 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | draft: 14 | name: "Draft Release" 15 | runs-on: ubuntu-latest 16 | timeout-minutes: 5 17 | permissions: 18 | contents: write 19 | 20 | steps: 21 | - name: "Checkout" 22 | uses: actions/checkout@v4 23 | 24 | - name: "Draft Release Action" 25 | id: draft 26 | uses: cssnr/draft-release-action@master 27 | with: 28 | semver: patch 29 | prerelease: false 30 | 31 | - name: "Process Release Draft URL" 32 | run: | 33 | echo "url: ${{ steps.draft.outputs.url }}" 34 | -------------------------------------------------------------------------------- /.github/assets/qr-code-firefox.json: -------------------------------------------------------------------------------- 1 | { 2 | "props": { 3 | "data": "https://addons.mozilla.org/addon/cache-cleaner-addon", 4 | "image": "", 5 | "width": 200, 6 | "height": 200, 7 | "margin": "", 8 | "dotsOptions": { "color": "#58beec", "type": "dots" }, 9 | "cornersSquareOptions": { "color": "#ee8424", "type": "dot" }, 10 | "cornersDotOptions": { "color": "#ffe513", "type": "dot" }, 11 | "imageOptions": { "margin": 1 }, 12 | "qrOptions": { "errorCorrectionLevel": "Q" } 13 | }, 14 | "style": { "borderRadius": "0px", "background": "transparent" }, 15 | "frame": { 16 | "text": "Firefox Android", 17 | "position": "top", 18 | "style": { 19 | "textColor": "#ededed", 20 | "backgroundColor": "#0d1117", 21 | "borderColor": "#ababab", 22 | "borderWidth": "2px", 23 | "borderRadius": "16px", 24 | "padding": "4px" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/css/auth.css: -------------------------------------------------------------------------------- 1 | /* CSS for options.html */ 2 | 3 | video { 4 | position: fixed; 5 | top: 0; 6 | left: 0; 7 | width: 100%; 8 | height: 100%; 9 | object-fit: cover; 10 | z-index: -1; 11 | } 12 | 13 | #auth-outer { 14 | max-width: 767px; 15 | backdrop-filter: blur(6px); 16 | } 17 | 18 | [data-bs-theme='dark'] #auth-outer { 19 | background-color: rgba(var(--bs-black-rgb), 0.5); 20 | border: 1px solid rgba(var(--bs-white-rgb), 0.2); 21 | filter: drop-shadow(15px 15px 12px var(--bs-black)); 22 | } 23 | 24 | [data-bs-theme='light'] #auth-outer { 25 | background-color: rgba(var(--bs-white-rgb), 0.5); 26 | border: 1px solid rgba(var(--bs-black-rgb), 0.2); 27 | filter: drop-shadow(15px 15px 12px var(--bs-white)); 28 | } 29 | 30 | [data-bs-theme='dark'] .form-control { 31 | background-color: rgba(var(--bs-black-rgb), 0.5); 32 | } 33 | 34 | [data-bs-theme='light'] .form-control { 35 | background-color: rgba(var(--bs-white-rgb), 0.5); 36 | } 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/0-bug.yaml: -------------------------------------------------------------------------------- 1 | name: "⚠️ Report an Issue" 2 | description: "Something Not Working Right? Please let us know..." 3 | labels: ["bug"] 4 | assignees: 5 | - smashedr 6 | 7 | body: 8 | - type: input 9 | id: website 10 | validations: 11 | required: false 12 | attributes: 13 | label: Site Link 14 | description: Please provide a link to the site you are having issues on if possible. 15 | placeholder: https://example.com/ 16 | 17 | - type: textarea 18 | id: description 19 | validations: 20 | required: true 21 | attributes: 22 | label: Details 23 | description: Please describe the issue you are experiencing and how to reproduce. 24 | placeholder: Provide as many details as you can... 25 | 26 | - type: textarea 27 | id: logs 28 | validations: 29 | required: true 30 | attributes: 31 | label: Support Information 32 | description: Open the extension options, scroll to the bottom, click Copy Support Information and paste below. 33 | render: shell 34 | 35 | - type: markdown 36 | attributes: 37 | value: | 38 | All issues/bugs that we can verify will be fixed. Thank you for taking the time to make this report! 39 | -------------------------------------------------------------------------------- /src/js/permissions.js: -------------------------------------------------------------------------------- 1 | // JS for permissions.html 2 | 3 | import { 4 | checkPerms, 5 | grantPerms, 6 | linkClick, 7 | onRemoved, 8 | updateManifest, 9 | } from './export.js' 10 | 11 | chrome.permissions.onAdded.addListener(onAdded) 12 | chrome.permissions.onRemoved.addListener(onRemoved) 13 | 14 | document.addEventListener('DOMContentLoaded', domContentLoaded) 15 | document 16 | .querySelectorAll('.grant-permissions') 17 | .forEach((el) => el.addEventListener('click', grantPerms)) 18 | document 19 | .querySelectorAll('a[href]') 20 | .forEach((el) => el.addEventListener('click', linkClick)) 21 | 22 | /** 23 | * DOMContentLoaded 24 | * @function domContentLoaded 25 | */ 26 | async function domContentLoaded() { 27 | console.debug('domContentLoaded') 28 | // noinspection ES6MissingAwait 29 | updateManifest() 30 | // noinspection ES6MissingAwait 31 | checkPerms() 32 | } 33 | 34 | /** 35 | * Permissions On Added Callback 36 | * @param permissions 37 | */ 38 | async function onAdded(permissions) { 39 | console.debug('onAdded', permissions) 40 | const hasPerms = await checkPerms() 41 | if (hasPerms && window.opener) { 42 | await chrome.runtime.openOptionsPage() 43 | window.close() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | const gulp = require('gulp') 2 | 3 | gulp.task('bootstrap', () => { 4 | return gulp 5 | .src([ 6 | 'node_modules/bootstrap/dist/css/bootstrap.min.css', 7 | 'node_modules/bootstrap/dist/js/bootstrap.bundle.min.js', 8 | ]) 9 | .pipe(gulp.dest('src/dist/bootstrap')) 10 | }) 11 | 12 | gulp.task('clipboard', () => { 13 | return gulp 14 | .src('node_modules/clipboard/dist/clipboard.min.js') 15 | .pipe(gulp.dest('src/dist/clipboard')) 16 | }) 17 | 18 | gulp.task('fontawesome', () => { 19 | return gulp 20 | .src( 21 | [ 22 | 'node_modules/@fortawesome/fontawesome-free/css/all.min.css', 23 | 'node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-*', 24 | 'node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-*', 25 | ], 26 | { 27 | base: 'node_modules/@fortawesome/fontawesome-free', 28 | encoding: false, 29 | } 30 | ) 31 | .pipe(gulp.dest('src/dist/fontawesome')) 32 | }) 33 | 34 | gulp.task('jquery', () => { 35 | return gulp 36 | .src('node_modules/jquery/dist/jquery.min.js') 37 | .pipe(gulp.dest('src/dist/jquery')) 38 | }) 39 | 40 | gulp.task( 41 | 'default', 42 | gulp.parallel('bootstrap', 'clipboard', 'fontawesome', 'jquery') 43 | ) 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "auto-auth", 3 | "scripts": { 4 | "postinstall": "npx gulp", 5 | "lint:eslint": "npx eslint src/js tests", 6 | "lint:web-ext": "npm run manifest:firefox && npx web-ext lint --source-dir ./src/ --ignore-files dist/**", 7 | "lint": "npm run lint:eslint && npm run lint:web-ext", 8 | "test": "npm run manifest:chrome && node tests/test.js", 9 | "chrome": "npm run manifest:chrome && web-ext run --source-dir ./src/ --target=chromium", 10 | "firefox": "npm run manifest:firefox && web-ext run --source-dir ./src/", 11 | "manifest:chrome": "npx json-merger -p --am concat -o src/manifest.json manifest.json manifest-chrome.json", 12 | "manifest:firefox": "npx json-merger -p --am concat -o src/manifest.json manifest.json manifest-firefox.json", 13 | "build:chrome": "npm run manifest:chrome && npx web-ext build -n {name}-chrome-{version}.zip -o -s src", 14 | "build:firefox": "npm run manifest:firefox && npx web-ext build -n {name}-firefox-{version}.zip -o -s src", 15 | "build": "npm run build:chrome && npm run build:firefox", 16 | "prettier": "npx prettier --check ." 17 | }, 18 | "dependencies": { 19 | "@fortawesome/fontawesome-free": "^7.0.0", 20 | "bootstrap": "^5.3.7", 21 | "clipboard": "^2.0.11", 22 | "jquery": "^3.7.1" 23 | }, 24 | "devDependencies": { 25 | "@eslint/js": "^9.32.0", 26 | "@types/chrome": "^0.1.1", 27 | "eslint": "^9.32.0", 28 | "gulp": "^5.0.1", 29 | "json-merger": "^3.0.0", 30 | "prettier": "^3.6.2", 31 | "puppeteer": "^24.15.0", 32 | "web-ext": "^8.9.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/html/panel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Auto Auth Panel 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 |
19 |

Auto Auth Panel

20 |

The extension panel has not yet been implemented...

21 |
22 |
23 |
24 |
25 | 26 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Auto Auth", 3 | "short_name": "Auto Auth", 4 | "description": "Automatic Basic HTTP Authentication Web Extension with Browser Synchronization, Import/Export Capability and More Options.", 5 | "homepage_url": "https://github.com/cssnr/auto-auth", 6 | "author": "Shane", 7 | "version": "0.0.1", 8 | "manifest_version": 3, 9 | "permissions": [ 10 | "contextMenus", 11 | "storage", 12 | "webRequest", 13 | "webRequestAuthProvider" 14 | ], 15 | "host_permissions": ["*://*/*"], 16 | "content_scripts": [ 17 | { 18 | "matches": ["*://*/*"], 19 | "js": ["js/content-script.js"] 20 | } 21 | ], 22 | "background": { "type": "module" }, 23 | "options_ui": { 24 | "page": "html/options.html", 25 | "open_in_tab": true 26 | }, 27 | "commands": { 28 | "_execute_action": { 29 | "suggested_key": { 30 | "default": "Alt+Shift+A" 31 | }, 32 | "description": "Show Popup Action" 33 | }, 34 | "openOptions": { 35 | "suggested_key": { 36 | "default": "Alt+Shift+X" 37 | }, 38 | "description": "Open Options Page" 39 | } 40 | }, 41 | "action": { 42 | "default_popup": "html/popup.html", 43 | "default_title": "Auto Auth", 44 | "default_icon": { 45 | "16": "images/logo16.png", 46 | "32": "images/logo32.png", 47 | "48": "images/logo48.png", 48 | "96": "images/logo96.png", 49 | "128": "images/logo128.png" 50 | } 51 | }, 52 | "icons": { 53 | "16": "images/logo16.png", 54 | "32": "images/logo32.png", 55 | "48": "images/logo48.png", 56 | "96": "images/logo96.png", 57 | "128": "images/logo128.png" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: "Test" 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "18 18 * * 1,3,5" 7 | pull_request: 8 | branches: [master] 9 | push: 10 | branches: [master] 11 | #paths: 12 | # - ".github/workflows/test.yaml" 13 | # - "src/**" 14 | # - "tests/**" 15 | # - "gulpfile.js" 16 | # - "manifest.json" 17 | # - "package.json" 18 | # - "package-lock.json" 19 | 20 | jobs: 21 | test: 22 | name: "Test" 23 | runs-on: ubuntu-latest 24 | timeout-minutes: 5 25 | if: ${{ !contains(github.event.head_commit.message, '#notest') }} 26 | permissions: 27 | contents: write 28 | pull-requests: write 29 | 30 | steps: 31 | - name: "Checkout" 32 | uses: actions/checkout@v4 33 | 34 | - name: "Setup Node 22" 35 | uses: actions/setup-node@v4 36 | with: 37 | node-version: 22 38 | #cache: npm 39 | 40 | - name: "Install" 41 | run: | 42 | npm install 43 | 44 | - name: "Test" 45 | id: test 46 | run: | 47 | npm run test 48 | 49 | - name: "Push Artifacts" 50 | uses: cssnr/push-artifacts-action@master 51 | if: ${{ github.event_name == 'pull_request' }} 52 | continue-on-error: true 53 | with: 54 | source: "tests/screenshots/" 55 | dest: "/static" 56 | host: ${{ secrets.RSYNC_HOST }} 57 | user: ${{ secrets.RSYNC_USER }} 58 | pass: ${{ secrets.RSYNC_PASS }} 59 | port: ${{ secrets.RSYNC_PORT }} 60 | webhost: "https://artifacts.hosted-domains.com" 61 | #webhook: ${{ secrets.DISCORD_WEBHOOK }} 62 | #token: ${{ secrets.GITHUB_TOKEN }} 63 | 64 | - name: "Schedule Failure Notification" 65 | uses: sarisia/actions-status-discord@v1 66 | if: ${{ failure() && github.event_name == 'schedule' }} 67 | with: 68 | webhook: ${{ secrets.DISCORD_WEBHOOK }} 69 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: "Build" 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [published] 7 | 8 | jobs: 9 | build: 10 | name: "Build" 11 | runs-on: ubuntu-latest 12 | timeout-minutes: 5 13 | 14 | steps: 15 | - name: "Checkout" 16 | uses: actions/checkout@v4 17 | 18 | - name: "Setup Node 22" 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version: 22 22 | cache: npm 23 | 24 | - name: "Install" 25 | run: | 26 | npm install 27 | 28 | - name: "Update Manifest Version" 29 | if: ${{ github.event_name == 'release' }} 30 | uses: cssnr/update-json-value-action@v1 31 | 32 | - name: "Build" 33 | run: | 34 | npm run build 35 | 36 | - name: "Upload to Actions" 37 | if: ${{ github.event_name == 'workflow_dispatch' }} 38 | uses: actions/upload-artifact@v4 39 | with: 40 | name: artifacts 41 | path: web-ext-artifacts/ 42 | 43 | - name: "Upload to Release" 44 | if: ${{ github.event_name == 'release' }} 45 | uses: svenstaro/upload-release-action@v2 46 | with: 47 | file: web-ext-artifacts/* 48 | tag: ${{ github.ref }} 49 | overwrite: true 50 | file_glob: true 51 | 52 | - name: "Update Release Notes Action" 53 | if: ${{ github.event_name == 'release' }} 54 | continue-on-error: true 55 | uses: smashedr/update-release-notes-action@master 56 | with: 57 | type: generic 58 | 59 | - name: "Package Changelog Action" 60 | if: ${{ github.event_name == 'release' }} 61 | continue-on-error: true 62 | uses: cssnr/package-changelog-action@v1 63 | 64 | - name: "Send Failure Notification" 65 | if: ${{ failure() && github.event_name == 'release' }} 66 | uses: sarisia/actions-status-discord@v1 67 | with: 68 | webhook: ${{ secrets.DISCORD_WEBHOOK }} 69 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: "Lint" 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | branches: [master] 7 | push: 8 | branches: [master] 9 | 10 | jobs: 11 | lint: 12 | name: "Lint" 13 | runs-on: ubuntu-latest 14 | timeout-minutes: 5 15 | if: ${{ !contains(github.event.head_commit.message, '#nolint') }} 16 | 17 | steps: 18 | - name: "Checkout" 19 | uses: actions/checkout@v4 20 | 21 | - name: "Setup Node 22" 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: 22 25 | #cache: npm 26 | 27 | - name: "Install" 28 | id: install 29 | run: | 30 | npm install 31 | 32 | - name: "ESLint" 33 | if: ${{ !cancelled() }} 34 | run: | 35 | npm run lint 36 | 37 | - name: "Prettier" 38 | if: ${{ !cancelled() }} 39 | run: | 40 | npm run prettier 41 | 42 | - name: "Yamllint" 43 | if: ${{ !cancelled() }} 44 | env: 45 | CONFIG: "{extends: relaxed, ignore: [node_modules/], rules: {line-length: {max: 119}}}" 46 | run: | 47 | echo "::group::List Files" 48 | yamllint -d '${{ env.CONFIG }}' --list-files . 49 | echo "::endgroup::" 50 | yamllint -d '${{ env.CONFIG }}' . 51 | 52 | - name: "Actionlint" 53 | if: ${{ !cancelled() }} 54 | run: | 55 | echo "::group::Download" 56 | loc=$(curl -sI https://github.com/rhysd/actionlint/releases/latest | grep -i '^location:') 57 | echo "loc: ${loc}" 58 | tag=$(echo "${loc}" | sed -E 's|.*/tag/v?(.*)|\1|' | tr -d '\t\r\n') 59 | echo "tag: ${tag}" 60 | url="https://github.com/rhysd/actionlint/releases/latest/download/actionlint_${tag}_linux_amd64.tar.gz" 61 | echo "url: ${url}" 62 | curl -sL "${url}" | tar xz -C "${RUNNER_TEMP}" actionlint 63 | file "${RUNNER_TEMP}/actionlint" 64 | "${RUNNER_TEMP}/actionlint" --version 65 | echo "::endgroup::" 66 | "${RUNNER_TEMP}/actionlint" -color -verbose -shellcheck= -pyflakes= 67 | -------------------------------------------------------------------------------- /src/js/main.js: -------------------------------------------------------------------------------- 1 | // Common JS for Extension Pages 2 | 3 | import { showToast } from './export.js' 4 | 5 | document.querySelectorAll('.form-control').forEach((el) => { 6 | el.addEventListener('focus', () => el.classList.remove('is-invalid')) 7 | }) 8 | 9 | // noinspection TypeScriptUMDGlobal 10 | if (typeof ClipboardJS !== 'undefined') { 11 | // noinspection TypeScriptUMDGlobal 12 | const clipboard = new ClipboardJS( 13 | '[data-clipboard-text],[data-clipboard-target]' 14 | ) 15 | clipboard.on('success', function (event) { 16 | // console.debug('clipboard.success:', event) 17 | const text = event.text.trim() 18 | console.debug(`text: "${text}"`) 19 | // noinspection JSUnresolvedReference 20 | if (event.trigger.dataset.toast) { 21 | // noinspection JSUnresolvedReference 22 | showToast(event.trigger.dataset.toast, 'success') 23 | } else { 24 | showToast('Copied to Clipboard', 'success') 25 | } 26 | }) 27 | clipboard.on('error', function (event) { 28 | console.log('clipboard.error:', event) 29 | showToast('Clipboard Copy Failed', 'warning') 30 | }) 31 | } 32 | 33 | const backToTop = document.getElementById('back-to-top') 34 | if (backToTop) { 35 | window.addEventListener('scroll', debounce(onScroll)) 36 | backToTop.addEventListener('click', () => { 37 | document.body.scrollTop = 0 38 | document.documentElement.scrollTop = 0 39 | }) 40 | } 41 | 42 | /** 43 | * On Scroll Callback 44 | * @function onScroll 45 | */ 46 | function onScroll() { 47 | if ( 48 | document.body.scrollTop > 20 || 49 | document.documentElement.scrollTop > 20 50 | ) { 51 | backToTop.style.display = 'block' 52 | } else { 53 | backToTop.style.display = 'none' 54 | } 55 | } 56 | 57 | /** 58 | * DeBounce Function 59 | * @function debounce 60 | * @param {Function} fn 61 | * @param {Number} timeout 62 | */ 63 | function debounce(fn, timeout = 250) { 64 | let timeoutID 65 | return (...args) => { 66 | clearTimeout(timeoutID) 67 | timeoutID = setTimeout(() => fn(...args), timeout) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/js/content-script.js: -------------------------------------------------------------------------------- 1 | // JS Content Script 2 | 3 | // console.log('%cAuto Auth: content-script.js', 'color: Lime') 4 | 5 | const url = new URL(window.location) 6 | let tabEnabled = false 7 | 8 | if (!chrome.storage.onChanged.hasListener(onChanged)) { 9 | // console.debug('Adding storage.onChanged Listener') 10 | chrome.storage.onChanged.addListener(onChanged) 11 | } 12 | 13 | ;(async () => { 14 | // const { options, sites } = await chrome.storage.sync.get([ 15 | // 'options', 16 | // 'sites', 17 | // ]) 18 | // console.debug('options, sites:', options, sites) 19 | // const { sites } = await chrome.storage.sync.get(['sites']) 20 | const creds = await chrome.runtime.sendMessage({ host: url.host }) 21 | // console.debug('creds:', creds) 22 | if (creds) { 23 | tabEnabled = true 24 | if (creds === 'ignored') { 25 | console.debug('%cSite is currently ignored.', 'color: Yellow') 26 | await chrome.runtime.sendMessage({ 27 | badgeText: 'Off', 28 | badgeColor: 'yellow', 29 | }) 30 | } else { 31 | console.debug('%cFound credentials for site.', 'color: LimeGreen') 32 | await chrome.runtime.sendMessage({ 33 | badgeText: 'On', 34 | badgeColor: 'green', 35 | }) 36 | } 37 | } 38 | })() 39 | 40 | /** 41 | * On Changed Callback 42 | * @function onChanged 43 | * @param {Object} changes 44 | * @param {String} namespace 45 | */ 46 | async function onChanged(changes, namespace) { 47 | // console.debug('onChanged:', changes, namespace) 48 | for (let [key, { oldValue, newValue }] of Object.entries(changes)) { 49 | if (namespace === 'sync' && key === 'options') { 50 | console.debug('options', oldValue, newValue) 51 | } 52 | if (namespace === 'sync' && key.startsWith(url.host[0])) { 53 | // console.debug('sites', oldValue, newValue) 54 | const hosts = newValue[url.host[0]] || {} 55 | if (tabEnabled && !(url.host in hosts)) { 56 | await chrome.runtime.sendMessage({ 57 | badgeText: '', 58 | }) 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/js/theme.js: -------------------------------------------------------------------------------- 1 | // JS Bootstrap Theme Switcher 2 | 3 | ;(() => { 4 | const getStoredTheme = () => localStorage.getItem('theme') 5 | const setStoredTheme = (theme) => localStorage.setItem('theme', theme) 6 | const getMediaMatch = () => 7 | window.matchMedia('(prefers-color-scheme: dark)').matches 8 | ? 'dark' 9 | : 'light' 10 | 11 | const getPreferredTheme = () => { 12 | const storedTheme = getStoredTheme() 13 | if (storedTheme) { 14 | return storedTheme 15 | } else { 16 | return getMediaMatch() 17 | } 18 | } 19 | 20 | const setTheme = (theme) => { 21 | // console.debug(`setTheme: ${theme}`) 22 | if (theme === 'auto') { 23 | document.documentElement.setAttribute( 24 | 'data-bs-theme', 25 | getMediaMatch() 26 | ) 27 | } else { 28 | document.documentElement.setAttribute('data-bs-theme', theme) 29 | } 30 | } 31 | 32 | const stored = getStoredTheme() 33 | if (!stored) { 34 | setStoredTheme('auto') 35 | } 36 | setTheme(getPreferredTheme()) 37 | 38 | const showActiveTheme = (theme) => { 39 | // console.debug(`showActiveTheme: ${theme}`) 40 | const themeIcon = document.querySelector('#theme-icon') 41 | if (!themeIcon) { 42 | // console.debug('No Theme Icon to Set.') 43 | return 44 | } 45 | document.querySelectorAll('[data-bs-theme-value]').forEach((el) => { 46 | if (el.dataset.bsThemeValue === theme) { 47 | const i = el.querySelector('i') 48 | themeIcon.className = i.className + ' fa-lg' 49 | el.classList.add('active') 50 | el.setAttribute('aria-pressed', 'true') 51 | } else { 52 | el.classList.remove('active') 53 | el.setAttribute('aria-pressed', 'false') 54 | } 55 | }) 56 | } 57 | 58 | window.addEventListener('storage', (event) => { 59 | // console.log('storage:', event) 60 | if (event.key === 'theme') { 61 | setTheme(event.newValue) 62 | showActiveTheme(event.newValue) 63 | } 64 | }) 65 | 66 | window 67 | .matchMedia('(prefers-color-scheme: dark)') 68 | .addEventListener('change', () => { 69 | const storedTheme = getStoredTheme() 70 | console.debug('prefers-color-scheme: change:', storedTheme) 71 | if (storedTheme === 'auto') { 72 | const preferred = getPreferredTheme() 73 | setTheme(preferred) 74 | } 75 | }) 76 | 77 | window.addEventListener('DOMContentLoaded', () => { 78 | const preferred = getPreferredTheme() 79 | // console.debug('DOMContentLoaded: preferred:', preferred) 80 | showActiveTheme(preferred) 81 | 82 | document.querySelectorAll('[data-bs-theme-value]').forEach((el) => { 83 | el.addEventListener('click', () => { 84 | const value = el.getAttribute('data-bs-theme-value') 85 | setStoredTheme(value) 86 | setTheme(value) 87 | showActiveTheme(value) 88 | }) 89 | }) 90 | }) 91 | })() 92 | -------------------------------------------------------------------------------- /src/html/permissions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Auto Auth Permissions 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 |
19 |
20 | Auto Auth 22 |

Auto Auth

23 |
24 |
25 |

To intercept authentication requests, host permissions are needed.

26 | 30 |
31 | 34 | 35 | Open Options 36 |
37 | Home Page 39 | 40 | Get Support 42 |
43 |
44 |
45 |
46 |
47 | 48 | 51 | 52 |
53 |
54 |
55 | 56 |
57 | 60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/js/popup.js: -------------------------------------------------------------------------------- 1 | // JS for popup.html 2 | 3 | import { 4 | Hosts, 5 | checkPerms, 6 | grantPerms, 7 | linkClick, 8 | saveOptions, 9 | showToast, 10 | updateManifest, 11 | updateOptions, 12 | } from './export.js' 13 | 14 | chrome.storage.onChanged.addListener(onChanged) 15 | 16 | document.addEventListener('DOMContentLoaded', initPopup) 17 | // noinspection JSCheckFunctionSignatures 18 | document 19 | .querySelectorAll('.grant-permissions') 20 | .forEach((el) => el.addEventListener('click', (e) => grantPerms(e, true))) 21 | // noinspection JSCheckFunctionSignatures 22 | document 23 | .querySelectorAll('a[href]') 24 | .forEach((el) => el.addEventListener('click', (e) => linkClick(e, true))) 25 | document 26 | .querySelectorAll('#options-form input') 27 | .forEach((el) => el.addEventListener('change', saveOptions)) 28 | document 29 | .querySelectorAll('[data-bs-toggle="tooltip"]') 30 | .forEach((el) => new bootstrap.Tooltip(el)) 31 | 32 | const confirmDelete = document.getElementById('confirm-delete') 33 | const confirmDeleteHost = document.getElementById('delete-host') 34 | const deleteModal = new bootstrap.Modal('#delete-modal') 35 | confirmDelete.addEventListener('click', deleteHost) 36 | 37 | const hostnameEl = document.getElementById('hostname') 38 | const deleteSaved = document.getElementById('delete-saved') 39 | const usernameEl = document.getElementById('username') 40 | 41 | /** 42 | * Initialize Popup 43 | * @function initPopup 44 | */ 45 | async function initPopup() { 46 | console.debug('initPopup') 47 | // noinspection ES6MissingAwait 48 | updateManifest() 49 | checkPerms().then((hasPerms) => { 50 | if (!hasPerms) console.log('%cMissing Host Permissions', 'color: Red') 51 | }) 52 | chrome.storage.sync 53 | .get(['options']) 54 | .then((items) => updateOptions(items.options)) 55 | 56 | if (chrome.runtime.lastError) { 57 | showToast(chrome.runtime.lastError.message, 'warning') 58 | } 59 | 60 | // Check Tab Permissions 61 | const [tab] = await chrome.tabs.query({ currentWindow: true, active: true }) 62 | console.debug('tab:', tab) 63 | if (tab.url) { 64 | const url = new URL(tab.url) 65 | const creds = await Hosts.get(url.host) 66 | if (creds) { 67 | if (creds === 'ignored') { 68 | hostnameEl.classList.add('border-warning') 69 | deleteSaved.querySelector('span').textContent = 70 | 'Remove Host from Ignore' 71 | } else { 72 | hostnameEl.classList.add('border-success') 73 | usernameEl.querySelector('span').textContent = 74 | creds.split(':')[0] 75 | usernameEl.classList.remove('d-none') 76 | } 77 | hostnameEl.textContent = url.host 78 | deleteSaved.classList.remove('d-none') 79 | deleteSaved.dataset.value = url.host 80 | deleteSaved.addEventListener('click', deleteHost) 81 | confirmDelete.dataset.value = url.host 82 | confirmDeleteHost.textContent = url.host 83 | } else { 84 | hostnameEl.textContent = 'No Credentials Found for Tab.' 85 | hostnameEl.classList.remove('border-success', 'border-warning') 86 | deleteSaved.classList.add('d-none') 87 | usernameEl.classList.add('d-none') 88 | } 89 | } else { 90 | hostnameEl.classList.add('border-danger-subtle') 91 | } 92 | } 93 | 94 | /** 95 | * Delete Host 96 | * TODO: Cleanup This Function, Elements, and Event Listeners 97 | * @function deleteHost 98 | * @param {MouseEvent} event 99 | */ 100 | async function deleteHost(event) { 101 | console.debug('deleteHost:', event) 102 | const host = event.currentTarget?.dataset?.value 103 | console.debug('host:', host) 104 | const confirm = event.currentTarget?.id !== 'confirm-delete' 105 | const { options } = await chrome.storage.sync.get(['options']) 106 | if (options.confirmDelete && !!confirm) { 107 | console.debug('Show Delete Modal') 108 | // confirmDelete.dataset.value = host 109 | // confirmDeleteHost.textContent = host 110 | deleteModal.show() 111 | return 112 | } 113 | await Hosts.delete(host) 114 | deleteModal.hide() 115 | await initPopup() 116 | showToast(`Removed: ${host}`) 117 | } 118 | 119 | /** 120 | * On Changed Callback 121 | * @function onChanged 122 | * @param {Object} changes 123 | * @param {String} namespace 124 | */ 125 | function onChanged(changes, namespace) { 126 | // console.debug('onChanged:', changes, namespace) 127 | for (let [key, { newValue }] of Object.entries(changes)) { 128 | if (namespace === 'sync' && key === 'options') { 129 | updateOptions(newValue) 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /tests/test.js: -------------------------------------------------------------------------------- 1 | const puppeteer = require('puppeteer') 2 | const path = require('path') 3 | const fs = require('fs') 4 | 5 | const sourceDir = 'src' 6 | const ssDir = 'tests/screenshots' 7 | 8 | let count = 1 9 | 10 | // if (fs.existsSync(ssDir)) {} 11 | fs.rmSync(ssDir, { recursive: true, force: true }) 12 | fs.mkdirSync(ssDir) 13 | 14 | /** 15 | * @function screenshot 16 | * @param {String} name 17 | * @param {Object} [options] 18 | * @return {Object} 19 | */ 20 | function ssOptions(name, options = {}) { 21 | const n = count.toString().padStart(2, '0') 22 | count++ 23 | const opts = { path: `${ssDir}/${n}_${name}.png` } 24 | Object.assign(opts, options) 25 | console.log('options:', opts) 26 | return opts 27 | } 28 | 29 | async function scrollPage(page) { 30 | await page.evaluate(() => { 31 | window.scrollBy({ 32 | top: window.innerHeight, 33 | left: 0, 34 | behavior: 'instant', 35 | }) 36 | }) 37 | await new Promise((resolve) => setTimeout(resolve, 500)) 38 | } 39 | 40 | /** 41 | * @function getPage 42 | * @param {puppeteer.Browser} browser 43 | * @param {String} name 44 | * @param {String} [size] 45 | * @return {Promise} 46 | */ 47 | async function getPage(browser, name, size) { 48 | console.debug(`getPage: ${name}`, size) 49 | const target = await browser.waitForTarget( 50 | (target) => target.type() === 'page' && target.url().endsWith(name) 51 | ) 52 | const page = await target.asPage() 53 | await page.emulateMediaFeatures([ 54 | { name: 'prefers-color-scheme', value: 'dark' }, 55 | ]) 56 | if (size) { 57 | const [width, height] = size.split('x').map((x) => parseInt(x)) 58 | await page.setViewport({ width, height }) 59 | } 60 | console.debug(`Adding Logger: ${name}`) 61 | page.on('console', (msg) => console.log(`console: ${name}:`, msg.text())) 62 | return page 63 | } 64 | 65 | ;(async () => { 66 | // Get Browser 67 | const pathToExtension = path.join(process.cwd(), sourceDir) 68 | console.log('pathToExtension:', pathToExtension) 69 | const browser = await puppeteer.launch({ 70 | args: [ 71 | `--disable-extensions-except=${pathToExtension}`, 72 | `--load-extension=${pathToExtension}`, 73 | '--no-sandbox', 74 | ], 75 | dumpio: true, 76 | // headless: false, 77 | // slowMo: 50, 78 | }) 79 | console.log('browser:', browser) 80 | 81 | // Get Worker 82 | const workerTarget = await browser.waitForTarget( 83 | (target) => 84 | target.type() === 'service_worker' && 85 | target.url().endsWith('service-worker.js') 86 | ) 87 | const worker = await workerTarget.worker() 88 | console.log('worker:', worker) 89 | 90 | await new Promise((resolve) => setTimeout(resolve, 1000)) 91 | 92 | // Popup 93 | await worker.evaluate('chrome.action.openPopup();') 94 | let popup = await getPage(browser, 'popup.html') 95 | console.log('popup:', popup) 96 | await popup.waitForNetworkIdle() 97 | console.log('innerWidth:', await popup.evaluate('window.innerWidth')) 98 | console.log('innerHeight:', await popup.evaluate('window.innerHeight')) 99 | console.log('userAgent:', await popup.evaluate('navigator.userAgent')) 100 | await popup.screenshot(ssOptions('popup')) 101 | await popup.locator('[href="../html/options.html"]').click() 102 | 103 | // Options 104 | await worker.evaluate('chrome.runtime.openOptionsPage();') 105 | const options = await getPage(browser, 'options.html', '600x900') 106 | console.log('options:', options) 107 | await options.waitForNetworkIdle() 108 | await options.screenshot(ssOptions('options')) 109 | 110 | await options.locator('#tempDisabled').click() 111 | await new Promise((resolve) => setTimeout(resolve, 500)) 112 | await options.screenshot(ssOptions('disabled')) 113 | 114 | await options.locator('#tempDisabled').click() 115 | await new Promise((resolve) => setTimeout(resolve, 500)) 116 | await options.screenshot(ssOptions('enabled')) 117 | 118 | const [fileChooser] = await Promise.all([ 119 | options.waitForFileChooser(), 120 | options.click('#import-file'), 121 | ]) 122 | await fileChooser.accept(['./tests/secrets.txt']) 123 | await scrollPage(options) 124 | await options.screenshot(ssOptions('import')) 125 | 126 | await options.locator('[title="Delete"][data-value="cssnr.com"]').click() 127 | // await options.evaluate((selector) => { 128 | // document.querySelectorAll(selector)[1].click() 129 | // }, 'a[title="Delete"]') 130 | await new Promise((resolve) => setTimeout(resolve, 500)) 131 | await options.screenshot(ssOptions('delete')) 132 | 133 | await options.locator('#confirm-delete').click() 134 | await new Promise((resolve) => setTimeout(resolve, 500)) 135 | await options.screenshot(ssOptions('delete-confirm')) 136 | 137 | await options.locator('[title="Edit"][data-value="httpbin.org"]').click() 138 | await new Promise((resolve) => setTimeout(resolve, 500)) 139 | await options.screenshot(ssOptions('edit')) 140 | 141 | await options.locator('#username').fill('changed') 142 | await options.keyboard.press('Enter') 143 | await new Promise((resolve) => setTimeout(resolve, 500)) 144 | await options.screenshot(ssOptions('edit-save')) 145 | 146 | // Page 147 | const page = await browser.newPage() 148 | await page.emulateMediaFeatures([ 149 | { name: 'prefers-color-scheme', value: 'dark' }, 150 | ]) 151 | page.on('console', (msg) => console.log(`console:`, msg.text())) 152 | console.log('page:', page) 153 | 154 | // Auth 155 | try { 156 | // Intercepting auth throws: Error: net::ERR_ABORTED 157 | await page.goto('https://authenticationtest.com/HTTPAuth/') 158 | } catch (e) { 159 | console.debug('e:', e) 160 | } 161 | await page.waitForNetworkIdle() 162 | await page.screenshot(ssOptions('success')) 163 | 164 | await worker.evaluate('chrome.action.openPopup();') 165 | popup = await getPage(browser, 'popup.html') 166 | console.log('popup:', popup) 167 | await popup.waitForNetworkIdle() 168 | await popup.screenshot(ssOptions('popup')) 169 | 170 | try { 171 | // Intercepting auth throws: Error: net::ERR_ABORTED 172 | await page.goto('https://httpbin.org/basic-auth/guest/guest') 173 | } catch (e) { 174 | console.debug('e:', e) 175 | } 176 | await page.waitForNetworkIdle() 177 | await page.screenshot(ssOptions('auth')) 178 | 179 | await page.locator('#username').fill('guest') 180 | await page.keyboard.press('Enter') 181 | await page.waitForNetworkIdle() 182 | await page.screenshot(ssOptions('httpbin')) 183 | 184 | await browser.close() 185 | })() 186 | -------------------------------------------------------------------------------- /src/js/auth.js: -------------------------------------------------------------------------------- 1 | // JS for auth.html 2 | 3 | import { Hosts, linkClick, showHidePassword, showToast } from './export.js' 4 | 5 | const searchParams = new URLSearchParams(window.location.search) 6 | const url = new URL(searchParams.get('url')) 7 | document.querySelectorAll('.host').forEach((el) => (el.textContent = url.host)) 8 | document.title = `Login for ${url.host}` 9 | document.getElementById('favicon').href = `${url.origin}/favicon.ico` 10 | 11 | document.addEventListener('DOMContentLoaded', domContentLoaded) 12 | document.getElementById('auth-form').addEventListener('submit', submitAuth) 13 | document.getElementById('ignore-host').addEventListener('click', ignoreHost) 14 | document 15 | .querySelectorAll('[data-paste-input]') 16 | .forEach((el) => el.addEventListener('click', pasteInput)) 17 | document 18 | .querySelectorAll('[data-show-hide]') 19 | .forEach((el) => el.addEventListener('click', showHidePassword)) 20 | document 21 | .querySelectorAll('a[href]') 22 | .forEach((el) => el.addEventListener('click', linkClick)) 23 | document 24 | .querySelectorAll('[data-bs-toggle="tooltip"]') 25 | .forEach((el) => new bootstrap.Tooltip(el)) 26 | 27 | const userInput = document.getElementById('username') 28 | const passInput = document.getElementById('password') 29 | 30 | const saveCreds = document.getElementById('saveCreds') 31 | saveCreds.addEventListener('change', saveChange) 32 | 33 | /** 34 | * DOMContentLoaded 35 | * @function domContentLoaded 36 | */ 37 | async function domContentLoaded() { 38 | console.debug('domContentLoaded:', searchParams, url) 39 | 40 | if (searchParams.get('fail')) { 41 | document.getElementById('fail').classList.remove('d-none') 42 | } 43 | 44 | const link = document.getElementById('link') 45 | link.textContent = url.href 46 | link.href = url.href 47 | document.getElementById('hostname').value = url.host 48 | 49 | const { options } = await chrome.storage.sync.get(['options']) 50 | const { session } = await chrome.storage.session.get(['session']) 51 | setBackground(options) 52 | 53 | const creds = await Hosts.get(url.host) 54 | // console.log('creds:', creds) 55 | 56 | const tempSave = sessionStorage.getItem(url.host) 57 | if (tempSave) { 58 | saveCreds.checked = !!parseInt(tempSave) 59 | } else { 60 | saveCreds.checked = options.defaultSave 61 | } 62 | if (!saveCreds.checked) { 63 | document.getElementById('save-session').classList.remove('d-none') 64 | if (creds) { 65 | document.getElementById('temp-alert').classList.remove('d-none') 66 | } 67 | } 68 | 69 | if (creds) { 70 | if (creds !== 'ignored') { 71 | const [username, password] = creds.split(':') 72 | const user = userInput 73 | user.value = username 74 | user.select() 75 | passInput.value = password 76 | } 77 | } else if (url.host in session) { 78 | const [username, password] = session[url.host].split(':') 79 | const user = userInput 80 | user.value = username 81 | user.select() 82 | passInput.value = password 83 | } 84 | } 85 | 86 | async function ignoreHost(event) { 87 | console.debug('ignoreHost:', event) 88 | // const { sites } = await chrome.storage.sync.get(['sites']) 89 | // // console.debug('sites:', sites) 90 | // sites[url.host] = 'ignored' 91 | // await chrome.storage.sync.set({ sites }) 92 | await Hosts.set(url.host, 'ignored') 93 | 94 | document.body.remove() 95 | // window.location = url.href 96 | // location.href = url.href 97 | const tab = await chrome.tabs.getCurrent() 98 | // console.debug('tab:', tab) 99 | await chrome.tabs.update(tab.id, { 100 | url: url.href, 101 | }) 102 | } 103 | 104 | async function submitAuth(event) { 105 | console.debug('submitAuth:', event) 106 | event.preventDefault() 107 | event.submitter.classList.add('disabled') 108 | document.getElementById('icon').className = 'fa-solid fa-sync fa-spin ms-2' 109 | 110 | const host = event.target.elements.hostname.value 111 | const user = event.target.elements.username.value 112 | const pass = event.target.elements.password.value 113 | // console.debug('host, user, pass:', host, user, pass) 114 | 115 | if (event.target.elements.saveCreds.checked) { 116 | // const { sites } = await chrome.storage.sync.get(['sites']) 117 | // sites[host] = `${user}:${pass}` 118 | // await chrome.storage.sync.set({ sites }) 119 | await Hosts.set(url.host, `${user}:${pass}`) 120 | console.log( 121 | '%cCredentials Saved.', 122 | `Loading: ${url.href}`, 123 | 'color: LimeGreen' 124 | ) 125 | } else { 126 | const { session } = await chrome.storage.session.get(['session']) 127 | session[host] = `${user}:${pass}` 128 | await chrome.storage.session.set({ session }) 129 | console.log( 130 | '%cCredentials Saved for Session Only.', 131 | `Loading: ${url.href}`, 132 | 'color: SpringGreen' 133 | ) 134 | } 135 | const tab = await chrome.tabs.getCurrent() 136 | // console.debug('tab:', tab) 137 | await chrome.tabs.update(tab.id, { 138 | url: url.href, 139 | }) 140 | } 141 | 142 | /** 143 | * TODO: Add Optional Permissions for clipboardRead 144 | * @function pasteInput 145 | * @param {MouseEvent} event 146 | * @return {Promise} 147 | */ 148 | async function pasteInput(event) { 149 | console.debug('pasteInput:', event) 150 | showToast('Feature Not Yet Implemented', 'warning') 151 | // const text = await navigator.clipboard.readText() 152 | // console.debug('text:', text) 153 | // console.debug('pasteInput:', event.currentTarget.dataset.pasteInput) 154 | // const input = document.querySelector(event.currentTarget.dataset.pasteInput) 155 | // console.debug('input:', input) 156 | // input.value = text 157 | } 158 | 159 | async function saveChange(event) { 160 | console.debug('saveChange:', event) 161 | // console.debug('event.currentTarget.checked:', event.currentTarget.checked) 162 | if (event.currentTarget.checked) { 163 | document.getElementById('save-session').classList.add('d-none') 164 | sessionStorage.setItem(url.host, '1') 165 | document.getElementById('temp-alert').classList.add('d-none') 166 | } else { 167 | document.getElementById('save-session').classList.remove('d-none') 168 | sessionStorage.setItem(url.host, '0') 169 | const creds = await Hosts.get(url.host) 170 | if (creds) { 171 | document.getElementById('temp-alert').classList.remove('d-none') 172 | } 173 | } 174 | } 175 | 176 | /** 177 | * Set Background 178 | * @function setBackground 179 | * @param {Object} options 180 | */ 181 | function setBackground(options) { 182 | console.debug('setBackground:', options.radioBackground) 183 | const video = document.querySelector('video') 184 | if (options.radioBackground === 'bgPicture') { 185 | const url = options.pictureURL || 'https://picsum.photos/1920/1080' 186 | document.body.style.background = `url('${url}') no-repeat center fixed` 187 | document.body.style.backgroundSize = 'cover' 188 | video.classList.add('d-none') 189 | } else if (options.radioBackground === 'bgVideo') { 190 | const src = options.videoURL // || '/media/loop.mp4' 191 | video.classList.remove('d-none') 192 | video.src = src 193 | document.body.style.cssText = '' 194 | } else { 195 | document.body.style.cssText = '' 196 | video.classList.add('d-none') 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /src/html/auth.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Login 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 | 21 |
22 |
23 | 24 | url 25 |
26 | 27 | 30 | 31 |
32 | 33 | 34 |
35 | 36 | 37 | 38 | 39 | 40 |
41 |
Basic Authentication Username.
42 | 43 | 44 |
45 | 46 | 51 | 52 | 53 | 54 | 55 |
56 |
Basic Authentication Password.
57 | 58 | 59 | 60 |
61 | 62 | 63 | 64 | 65 | Credentials will not be saved! 66 | 67 |
68 | 69 |
70 | Credentials are already saved for this host and temporary credentials will have no effect! 71 |
72 | Until this is fixed you can enable Save Login or 73 | delete the saved credentials. 74 |
75 | 76 |
77 |
78 | 82 |
83 |
84 | 88 |
89 |
90 | 91 |
92 | 93 |
94 | 95 |
96 | Open Options 97 | 98 | Get Support 100 |
101 | 102 |
103 |
104 | 105 | 124 | 125 | 128 | 129 |
130 |
131 |
132 | 133 |
134 | 137 |
138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /src/html/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Auto Auth 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 | Auto Auth 20 |
21 | 22 |
23 | Auto Auth 24 | 25 | 26 | v 27 | 28 |
29 | 30 | 42 |
43 |
44 | 45 |
46 | 47 |
48 |
49 | 55 |

56 | More Information on Permissions 57 |

58 | 61 |
62 | 63 |
64 |
65 | No Access to the Current Tab. 66 |
67 | 71 |
72 | Username: 73 |
74 |
75 | 76 |
77 |
78 | 80 | 81 | 82 |
83 | 86 |
87 | 88 | 89 | 90 |
91 |
92 | 93 | 94 | 95 |
96 |
97 | 98 | 99 | 100 |
101 |
102 | 103 | 104 | 105 |
106 |
107 | 108 | 109 | 110 |
111 |
112 | 113 | 114 | More Options 115 |
116 | 117 | 137 | 138 |
139 |
140 |
141 | 142 |
143 | 146 |
147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /src/js/export.js: -------------------------------------------------------------------------------- 1 | // JS Exports 2 | 3 | export const githubURL = 'https://github.com/cssnr/auto-auth' 4 | 5 | export class Hosts { 6 | /** @type {[String]} */ 7 | static keys = [...'abcdefghijklmnopqrstuvwxyz0123456789'] 8 | 9 | /** 10 | * @return {Promise>} 11 | */ 12 | static async all() { 13 | const sync = await chrome.storage.sync.get(Hosts.keys) 14 | return Object.assign({}, ...Object.values(sync)) 15 | } 16 | 17 | /** 18 | * @param {String} host 19 | * @return {Promise} 20 | */ 21 | static async get(host) { 22 | const sync = await Hosts.#getSync(host) 23 | return sync[host] 24 | } 25 | 26 | /** 27 | * @param {String} host 28 | * @param {String} creds 29 | * @return {Promise} 30 | */ 31 | static async set(host, creds) { 32 | const sync = await Hosts.#getSync(host) 33 | sync[host] = creds 34 | await chrome.storage.sync.set({ [host[0]]: sync }) 35 | } 36 | 37 | /** 38 | * @param {String} host 39 | * @return {Promise} 40 | */ 41 | static async delete(host) { 42 | const sync = await Hosts.#getSync(host) 43 | delete sync[host] 44 | await chrome.storage.sync.set({ [host[0]]: sync }) 45 | } 46 | 47 | /** 48 | * @param {String} old 49 | * @param {String} host 50 | * @param {String} creds 51 | * @return {Promise} 52 | */ 53 | static async edit(old, host, creds) { 54 | if (old !== host) { 55 | await this.delete(old) 56 | } 57 | await this.set(host, creds) 58 | } 59 | 60 | /** 61 | * @param {Object} hosts 62 | * @return {Promise} 63 | */ 64 | static async update(hosts) { 65 | const sync = await chrome.storage.sync.get(Hosts.keys) 66 | for (const [key, value] of Object.entries(hosts)) { 67 | if (!(key[0] in sync)) { 68 | sync[key[0]] = {} 69 | } 70 | sync[key[0]][key] = value 71 | } 72 | await chrome.storage.sync.set(sync) 73 | } 74 | 75 | /** 76 | * @param {String} host 77 | * @return {Promise>} 78 | */ 79 | static async #getSync(host) { 80 | const sync = await chrome.storage.sync.get(host[0]) 81 | return sync[host[0]] || {} 82 | } 83 | } 84 | 85 | /** 86 | * Text File Download 87 | * @function textFileDownload 88 | * @param {String} filename 89 | * @param {String} text 90 | */ 91 | export function textFileDownload(filename, text) { 92 | console.debug(`textFileDownload: ${filename}`) 93 | const element = document.createElement('a') 94 | element.setAttribute( 95 | 'href', 96 | 'data:text/plain;charset=utf-8,' + encodeURIComponent(text) 97 | ) 98 | element.setAttribute('download', filename) 99 | element.classList.add('d-none') 100 | document.body.appendChild(element) 101 | element.click() 102 | document.body.removeChild(element) 103 | } 104 | 105 | export function showHidePassword(event) { 106 | console.debug('showHidePassword:', event) 107 | const el = event.currentTarget 108 | const input = document.querySelector(el.dataset.showHide) 109 | if (input.type === 'password') { 110 | input.type = 'text' 111 | el.classList.remove(el.dataset.classOff) 112 | el.classList.add(el.dataset.classOn) 113 | } else { 114 | input.type = 'password' 115 | el.classList.remove(el.dataset.classOn) 116 | el.classList.add(el.dataset.classOff) 117 | } 118 | } 119 | 120 | /** 121 | * Show Extension Panel 122 | * @function showPanel 123 | * @param {Number} height 124 | * @param {Number} width 125 | */ 126 | export async function showPanel(height = 520, width = 480) { 127 | return await chrome.windows.create({ 128 | type: 'panel', 129 | url: '/html/panel.html', 130 | width, 131 | height, 132 | }) 133 | } 134 | 135 | /** 136 | * @function copyInput 137 | * @param {MouseEvent} event 138 | * @return {Promise} 139 | */ 140 | export async function copyInput(event) { 141 | console.debug('copyInput:', event) 142 | const el = event.currentTarget || event.target.closest('button') 143 | console.debug('el.dataset.copyInput:', el.dataset.copyInput) 144 | const input = document.querySelector(el.dataset.copyInput) 145 | console.debug('input:', input) 146 | if (!input.value) { 147 | showToast('No Data to Copy.', 'warning') 148 | return 149 | } 150 | await navigator.clipboard.writeText(input.value) 151 | if (el.dataset.copyText) { 152 | showToast(el.dataset.copyText, 'success') 153 | } else { 154 | showToast('Copied to Clipboard.', 'success') 155 | } 156 | } 157 | 158 | /** 159 | * Save Options Callback 160 | * @function saveOptions 161 | * @param {UIEvent} event 162 | */ 163 | export async function saveOptions(event) { 164 | console.debug('saveOptions:', event) 165 | const { options } = await chrome.storage.sync.get(['options']) 166 | let key = event.target.id 167 | let value 168 | if (event.target.type === 'radio') { 169 | key = event.target.name 170 | const radios = document.getElementsByName(key) 171 | for (const input of radios) { 172 | if (input.checked) { 173 | value = input.id 174 | break 175 | } 176 | } 177 | } else if (event.target.type === 'checkbox') { 178 | value = event.target.checked 179 | } else if (event.target.type === 'number') { 180 | value = event.target.value.toString() 181 | } else { 182 | value = event.target.value 183 | } 184 | if (value !== undefined) { 185 | options[key] = value 186 | console.log(`%cSet: ${key}:`, 'color: Lime', value) 187 | await chrome.storage.sync.set({ options }) 188 | } else { 189 | console.warn('No Value for key:', key) 190 | } 191 | } 192 | 193 | /** 194 | * Update Options based on type 195 | * @function initOptions 196 | * @param {Object} options 197 | */ 198 | export function updateOptions(options) { 199 | console.debug('updateOptions:', options) 200 | for (let [key, value] of Object.entries(options)) { 201 | if (typeof value === 'undefined') { 202 | console.warn('Value undefined for key:', key) 203 | continue 204 | } 205 | // Option Key should be `radioXXX` and values should be the option IDs 206 | if (key.startsWith('radio')) { 207 | key = value 208 | value = true 209 | } 210 | // console.debug(`${key}: ${value}`) 211 | const el = document.getElementById(key) 212 | if (!el) { 213 | continue 214 | } 215 | if (el.tagName !== 'INPUT') { 216 | el.textContent = value.toString() 217 | } else if (['checkbox', 'radio'].includes(el.type)) { 218 | el.checked = value 219 | } else { 220 | el.value = value 221 | } 222 | if (el.dataset.related) { 223 | hideShowElement(`#${el.dataset.related}`, value) 224 | } 225 | if (el.dataset.warning) { 226 | addWarningClass(el.nextElementSibling, value, el.dataset.warning) 227 | } 228 | } 229 | } 230 | 231 | /** 232 | * Hide or Show Element with JQuery 233 | * @function hideShowElement 234 | * @param {String} selector 235 | * @param {Boolean} [show] 236 | * @param {String} [speed] 237 | */ 238 | function hideShowElement(selector, show, speed = 'fast') { 239 | const element = $(`${selector}`) 240 | // console.debug('hideShowElement:', show, element) 241 | if (show) { 242 | element.show(speed) 243 | } else { 244 | element.hide(speed) 245 | } 246 | } 247 | 248 | /** 249 | * Add Warning Class to Element 250 | * @function addWarningClass 251 | * @param {HTMLElement} element 252 | * @param {Boolean} value 253 | * @param {String} warning 254 | */ 255 | function addWarningClass(element, value, warning) { 256 | // console.debug('addWarningClass:', value, element) 257 | if (value) { 258 | element.classList.add(warning) 259 | } else { 260 | element.classList.remove(warning) 261 | } 262 | } 263 | 264 | /** 265 | * Link Click Callback 266 | * Firefox requires a call to window.close() 267 | * @function linkClick 268 | * @param {MouseEvent} event 269 | * @param {Boolean} [close] 270 | */ 271 | export async function linkClick(event, close = false) { 272 | // console.debug('linkClick:', event, close) 273 | event.preventDefault() 274 | const href = event.currentTarget.getAttribute('href').replace(/^\.+/g, '') 275 | // console.debug('href:', href) 276 | if (href.startsWith('#')) { 277 | // console.debug('return on anchor link') 278 | return 279 | } 280 | let url 281 | if (href.endsWith('html/options.html')) { 282 | await chrome.runtime.openOptionsPage() 283 | if (close) window.close() 284 | return 285 | } else if (href.endsWith('html/panel.html')) { 286 | await showPanel() 287 | if (close) window.close() 288 | return 289 | } else if (href.startsWith('http')) { 290 | url = href 291 | } else { 292 | url = chrome.runtime.getURL(href) 293 | } 294 | console.debug('url:', url) 295 | await activateOrOpen(url) 296 | if (close) window.close() 297 | } 298 | 299 | /** 300 | * Activate or Open Tab from URL 301 | * @function activateOrOpen 302 | * @param {String} url 303 | * @param {Boolean} [open] 304 | * @return {Promise} 305 | */ 306 | export async function activateOrOpen(url, open = true) { 307 | console.debug('activateOrOpen:', url) 308 | // Get Tab from Tabs (requires host permissions) 309 | const tabs = await chrome.tabs.query({ currentWindow: true }) 310 | // console.debug('tabs:', tabs) 311 | for (const tab of tabs) { 312 | if (tab.url === url) { 313 | console.debug('found tab in tabs:', tab) 314 | return await chrome.tabs.update(tab.id, { active: true }) 315 | } 316 | } 317 | console.debug('tab not found, open:', open) 318 | if (open) { 319 | return await chrome.tabs.create({ active: true, url }) 320 | } 321 | } 322 | 323 | /** 324 | * Update DOM with Manifest Details 325 | * @function updateManifest 326 | */ 327 | export async function updateManifest() { 328 | try { 329 | const manifest = chrome.runtime.getManifest() 330 | document.querySelectorAll('.version').forEach((el) => { 331 | el.textContent = manifest.version 332 | }) 333 | document.querySelectorAll('[href="version_url"]').forEach((el) => { 334 | el.href = `${githubURL}/releases/tag/${manifest.version}` 335 | }) 336 | document.querySelectorAll('[href="homepage_url"]').forEach((el) => { 337 | el.href = manifest.homepage_url 338 | }) 339 | } catch (e) { 340 | console.log('Error updating manifest settings:', e) 341 | } 342 | } 343 | 344 | /** 345 | * Check Host Permissions 346 | * @function checkPerms 347 | * @return {Promise} 348 | */ 349 | export async function checkPerms() { 350 | const hasPerms = await chrome.permissions.contains({ 351 | origins: ['*://*/*'], 352 | }) 353 | console.debug('checkPerms:', hasPerms) 354 | // Firefox still uses DOM Based Background Scripts 355 | if (typeof document === 'undefined') { 356 | return hasPerms 357 | } 358 | const hasPermsEl = document.querySelectorAll('.has-perms') 359 | const grantPermsEl = document.querySelectorAll('.grant-perms') 360 | if (hasPerms) { 361 | hasPermsEl.forEach((el) => el.classList.remove('d-none')) 362 | grantPermsEl.forEach((el) => el.classList.add('d-none')) 363 | } else { 364 | grantPermsEl.forEach((el) => el.classList.remove('d-none')) 365 | hasPermsEl.forEach((el) => el.classList.add('d-none')) 366 | } 367 | return hasPerms 368 | } 369 | 370 | /** 371 | * Grant Permissions Click Callback 372 | * @function grantPerms 373 | * @param {MouseEvent} event 374 | * @param {Boolean} [close] 375 | */ 376 | export async function grantPerms(event, close = false) { 377 | console.debug('grantPerms:', event) 378 | // noinspection ES6MissingAwait 379 | requestPerms() 380 | if (close) { 381 | window.close() 382 | } 383 | } 384 | 385 | /** 386 | * Request Host Permissions 387 | * @function requestPerms 388 | * @return {Promise} 389 | */ 390 | export async function requestPerms() { 391 | return await chrome.permissions.request({ 392 | origins: ['*://*/*'], 393 | }) 394 | } 395 | 396 | /** 397 | * Revoke Permissions Click Callback 398 | * NOTE: For many reasons Chrome will determine host_perms are required and 399 | * will ask for them at install time and not allow them to be revoked 400 | * @function revokePerms 401 | * @param {MouseEvent} event 402 | */ 403 | export async function revokePerms(event) { 404 | console.debug('revokePerms:', event) 405 | const permissions = await chrome.permissions.getAll() 406 | console.debug('permissions:', permissions) 407 | try { 408 | await chrome.permissions.remove({ 409 | origins: permissions.origins, 410 | }) 411 | await checkPerms() 412 | } catch (e) { 413 | console.log(`%cError: ${e.message}`, 'color: Red', e) 414 | showToast(e.toString(), 'danger') 415 | } 416 | } 417 | 418 | /** 419 | * Permissions On Added Callback 420 | * @param {chrome.permissions} permissions 421 | */ 422 | export async function onAdded(permissions) { 423 | console.debug('onAdded', permissions) 424 | await checkPerms() 425 | } 426 | 427 | /** 428 | * Permissions On Removed Callback 429 | * @param {chrome.permissions} permissions 430 | */ 431 | export async function onRemoved(permissions) { 432 | console.debug('onRemoved', permissions) 433 | await checkPerms() 434 | } 435 | 436 | /** 437 | * @function updateBrowser 438 | * @return {Promise} 439 | */ 440 | export async function updateBrowser() { 441 | let selector = '.chrome' 442 | // noinspection JSUnresolvedReference 443 | if (typeof browser !== 'undefined') { 444 | selector = '.firefox' 445 | } 446 | document 447 | .querySelectorAll(selector) 448 | .forEach((el) => el.classList.remove('d-none')) 449 | } 450 | 451 | /** 452 | * Show Bootstrap Toast 453 | * @function showToast 454 | * @param {String} message 455 | * @param {String} type 456 | */ 457 | export function showToast(message, type = 'primary') { 458 | console.debug(`showToast: ${type}: ${message}`) 459 | const clone = document.querySelector('#clones > .toast') 460 | const container = document.getElementById('toast-container') 461 | if (!clone || !container) { 462 | return console.warn('Missing clone or container:', clone, container) 463 | } 464 | const element = clone.cloneNode(true) 465 | element.querySelector('.toast-body').innerHTML = message 466 | element.classList.add(`text-bg-${type}`) 467 | container.appendChild(element) 468 | const toast = new bootstrap.Toast(element) 469 | element.addEventListener('mousemove', () => toast.hide()) 470 | toast.show() 471 | } 472 | -------------------------------------------------------------------------------- /src/js/service-worker.js: -------------------------------------------------------------------------------- 1 | // JS Background Service Worker 2 | 3 | import { Hosts, checkPerms, showPanel, githubURL } from './export.js' 4 | 5 | chrome.runtime.onInstalled.addListener(onInstalled) 6 | chrome.runtime.onStartup.addListener(onStartup) 7 | chrome.contextMenus?.onClicked.addListener(onClicked) 8 | chrome.commands?.onCommand.addListener(onCommand) 9 | chrome.runtime.onMessage.addListener(onMessage) 10 | chrome.storage.onChanged.addListener(onChanged) 11 | chrome.permissions.onAdded.addListener(onAdded) 12 | chrome.permissions.onRemoved.addListener(onRemoved) 13 | 14 | chrome.webRequest.onAuthRequired.addListener( 15 | onAuthRequired, 16 | { urls: [''] }, 17 | ['asyncBlocking'] 18 | ) 19 | chrome.webRequest.onCompleted.addListener(webRequestFinished, { 20 | urls: [''], 21 | }) 22 | chrome.webRequest.onErrorOccurred.addListener(webRequestFinished, { 23 | urls: [''], 24 | }) 25 | 26 | const pendingRequests = [] 27 | 28 | async function onAuthRequired(details, callback) { 29 | console.debug('onAuthRequired:', details) 30 | // const { options, sites } = await chrome.storage.sync.get([ 31 | // 'options', 32 | // 'sites', 33 | // ]) 34 | // console.debug('options, sites:', options, sites) 35 | let { options } = await chrome.storage.sync.get(['options']) 36 | if (options.tempDisabled) { 37 | console.log('%cExtension is Temporarily Disabled!', 'color: Red') 38 | return callback() 39 | } 40 | if (options.ignoreProxy && details.statusCode === 407) { 41 | console.log('%cIgnoring Proxy Authentication!', 'color: Yellow') 42 | return callback() 43 | } 44 | const url = new URL(details.url) 45 | // console.debug('url.host:', url.host) 46 | 47 | const hijackRequest = (failed = false) => { 48 | if (details.tabId === -1) { 49 | console.warn(`Unable to process tab:`, details) 50 | return callback() 51 | } 52 | console.log( 53 | `Cancel Request and Hijack w/ failed: %c${failed}`, 54 | `color: ${failed ? 'Yellow' : 'Lime'}` 55 | ) 56 | const auth = new URL(chrome.runtime.getURL('/html/auth.html')) 57 | auth.searchParams.append('url', details.url) 58 | if (failed) { 59 | auth.searchParams.append('fail', 'yes') 60 | } 61 | chrome.tabs.update(details.tabId, { 62 | url: auth.href, 63 | }) 64 | callback({ cancel: true }) 65 | } 66 | 67 | // Check if Request Already Processed 68 | if (pendingRequests.includes(details.requestId)) { 69 | console.log( 70 | `%cAlready Processed Request ID: ${details.requestId}`, 71 | 'color: Orange' 72 | ) 73 | hijackRequest(true) 74 | } 75 | pendingRequests.push(details.requestId) 76 | 77 | const creds = await Hosts.get(url.host) 78 | // console.log('creds:', creds) 79 | 80 | // Check for Saved Credentials 81 | if (creds) { 82 | if (creds === 'ignored') { 83 | console.log( 84 | `%cHost is Set to Ignored: %c${url.host}`, 85 | 'color: Yellow', 86 | 'color: Violet' 87 | ) 88 | return callback() 89 | } 90 | console.log( 91 | `%cSending Saved Creds for: ${details.requestId}`, 92 | 'color: LimeGreen' 93 | ) 94 | const [username, password] = creds.split(':') 95 | const authCredentials = { 96 | username, 97 | password, 98 | } 99 | // console.debug('authCredentials:', authCredentials) 100 | return callback({ authCredentials }) 101 | } 102 | 103 | // Check for Temporary Credentials 104 | const { session } = await chrome.storage.session.get(['session']) 105 | if (url.host in session) { 106 | console.log( 107 | `%cSending Session Creds for: ${details.requestId}`, 108 | 'color: SpringGreen' 109 | ) 110 | const [username, password] = session[url.host].split(':') 111 | const authCredentials = { 112 | username, 113 | password, 114 | } 115 | // console.debug('authCredentials:', authCredentials) 116 | return callback({ authCredentials }) 117 | } 118 | 119 | // New Request Without Credentials 120 | console.log( 121 | `%cNo Credentials for Request ID: ${details.requestId}`, 122 | 'color: DeepSkyBlue' 123 | ) 124 | hijackRequest() 125 | } 126 | 127 | function webRequestFinished(requestDetails) { 128 | // console.debug(`webRequestFinished: ${requestDetails.requestId}`) 129 | let index = pendingRequests.indexOf(requestDetails.requestId) 130 | if (index > -1) { 131 | console.debug( 132 | `%cRemoving pendingRequests: ${requestDetails.requestId}`, 133 | 'color: Khaki' 134 | ) 135 | pendingRequests.splice(index, 1) 136 | } 137 | } 138 | 139 | /** 140 | * On Installed Callback 141 | * @function onInstalled 142 | * @param {chrome.runtime.InstalledDetails} details 143 | */ 144 | async function onInstalled(details) { 145 | console.log('onInstalled:', details) 146 | const options = await setDefaultOptions({ 147 | tempDisabled: false, 148 | ignoreProxy: false, 149 | defaultSave: true, 150 | confirmDelete: true, 151 | contextMenu: true, 152 | showUpdate: false, 153 | radioBackground: 'bgPicture', 154 | pictureURL: 'https://picsum.photos/1920/1080', 155 | videoURL: '', 156 | }) 157 | console.debug('options:', options) 158 | await updateIcon(options) 159 | if (options.contextMenu) { 160 | createContextMenus() 161 | } 162 | const manifest = chrome.runtime.getManifest() 163 | if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) { 164 | const hasPerms = await checkPerms() 165 | if (hasPerms) { 166 | await chrome.runtime.openOptionsPage() 167 | } else { 168 | const url = chrome.runtime.getURL('/html/permissions.html') 169 | await chrome.tabs.create({ active: true, url }) 170 | } 171 | } else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) { 172 | if (options.showUpdate) { 173 | if (manifest.version !== details.previousVersion) { 174 | const url = `${githubURL}/releases/tag/${manifest.version}` 175 | await chrome.tabs.create({ active: false, url }) 176 | } 177 | } 178 | } 179 | setUninstallURL() 180 | } 181 | 182 | /** 183 | * On Startup Callback 184 | * @function onStartup 185 | */ 186 | async function onStartup() { 187 | console.log('onStartup') 188 | const { session } = await chrome.storage.session.get(['session']) 189 | if (!session) { 190 | await chrome.storage.session.set({ session: {} }) 191 | console.debug('onStartup: Initialized Empty session') 192 | } 193 | const { options } = await chrome.storage.sync.get(['options']) 194 | // console.debug('options:', options) 195 | await updateIcon(options) 196 | // noinspection JSUnresolvedReference 197 | if (typeof browser !== 'undefined') { 198 | console.log('Firefox CTX Menu Workaround') 199 | if (options.contextMenu) { 200 | createContextMenus() 201 | } 202 | setUninstallURL() 203 | } 204 | } 205 | 206 | function setUninstallURL() { 207 | // const manifest = chrome.runtime.getManifest() 208 | // const url = new URL('https://link-extractor.cssnr.com/uninstall/') 209 | // url.searchParams.append('version', manifest.version) 210 | // chrome.runtime.setUninstallURL(url.href) 211 | // console.debug(`setUninstallURL: ${url.href}`) 212 | chrome.runtime.setUninstallURL(`${githubURL}/issues`) 213 | console.debug(`setUninstallURL: ${githubURL}/issues`) 214 | } 215 | 216 | /** 217 | * On Clicked Callback 218 | * @function onClicked 219 | * @param {OnClickData} ctx 220 | * @param {Tab} tab 221 | */ 222 | async function onClicked(ctx, tab) { 223 | console.debug('onClicked:', ctx, tab) 224 | if (ctx.menuItemId === 'openOptions') { 225 | await chrome.runtime.openOptionsPage() 226 | } else if (ctx.menuItemId === 'showPanel') { 227 | await showPanel() 228 | } else { 229 | console.error(`Unknown ctx.menuItemId: ${ctx.menuItemId}`) 230 | } 231 | } 232 | 233 | /** 234 | * On Command Callback 235 | * @function onCommand 236 | * @param {String} command 237 | */ 238 | async function onCommand(command) { 239 | console.debug('onCommand:', command) 240 | if (command === 'openOptions') { 241 | await chrome.runtime.openOptionsPage() 242 | } else if (command === 'showPanel') { 243 | await showPanel() 244 | } else { 245 | console.error(`Unknown command: ${command}`) 246 | } 247 | } 248 | 249 | /** 250 | * Message Callback - this function must not async 251 | * @function onMessage 252 | * @param {Object} message 253 | * @param {String} [message.badgeColor] 254 | * @param {String} [message.badgeText] 255 | * @param {Number} [message.tabId] 256 | * @param {Function} sendResponse 257 | * @param {MessageSender} sender 258 | */ 259 | function onMessage(message, sender, sendResponse) { 260 | console.debug('message, sender:', message, sender) 261 | const tabId = message.tabId || sender.tab?.id 262 | if ('badgeColor' in message && tabId) { 263 | console.debug(`tabId: ${tabId} color: ${message.badgeColor}`) 264 | // noinspection JSIgnoredPromiseFromCall 265 | chrome.action.setBadgeBackgroundColor({ 266 | tabId: tabId, 267 | color: message.badgeColor, 268 | }) 269 | } 270 | if ('badgeText' in message && tabId) { 271 | console.debug(`tabId: ${tabId} text: ${message.badgeText}`) 272 | // noinspection JSIgnoredPromiseFromCall 273 | chrome.action.setBadgeText({ 274 | tabId: tabId, 275 | text: message.badgeText, 276 | }) 277 | } 278 | if ('host' in message) { 279 | Hosts.get(message.host).then((creds) => sendResponse(creds)) 280 | return true 281 | } 282 | } 283 | 284 | /** 285 | * On Changed Callback 286 | * @function onChanged 287 | * @param {Object} changes 288 | * @param {String} namespace 289 | */ 290 | async function onChanged(changes, namespace) { 291 | // console.debug('onChanged:', changes, namespace) 292 | for (const [key, { oldValue, newValue }] of Object.entries(changes)) { 293 | if (namespace === 'sync' && key === 'options' && oldValue && newValue) { 294 | if (oldValue.contextMenu !== newValue.contextMenu) { 295 | if (newValue?.contextMenu) { 296 | console.info('Enabled contextMenu...') 297 | createContextMenus() 298 | } else { 299 | console.info('Disabled contextMenu...') 300 | chrome.contextMenus?.removeAll() 301 | } 302 | } 303 | if (oldValue.tempDisabled !== newValue.tempDisabled) { 304 | console.debug('tempDisabled:', newValue.tempDisabled) 305 | // const color = newValue.tempDisabled ? 'red' : 'green' 306 | await updateIcon(newValue) 307 | } 308 | } 309 | } 310 | } 311 | 312 | /** 313 | * Permissions On Added Callback 314 | * @param {chrome.permissions} permissions 315 | */ 316 | export async function onAdded(permissions) { 317 | console.debug('onAdded', permissions) 318 | await updateIcon() 319 | } 320 | 321 | /** 322 | * Permissions On Removed Callback 323 | * @param {chrome.permissions} permissions 324 | */ 325 | export async function onRemoved(permissions) { 326 | console.debug('onRemoved', permissions) 327 | await updateIcon() 328 | } 329 | 330 | async function updateIcon(options) { 331 | if (!options) { 332 | const data = await chrome.storage.sync.get(['options']) 333 | options = data.options 334 | } 335 | console.debug('updateIcon options.tempDisabled:', options.tempDisabled) 336 | const hasPerms = await checkPerms() 337 | let color 338 | if (!hasPerms) { 339 | color = 'red' 340 | } else if (options.tempDisabled) { 341 | color = 'yellow' 342 | } else { 343 | color = 'green' 344 | } 345 | console.debug('color', color) 346 | 347 | if (color === 'red') { 348 | console.debug('Setting Red Icon') 349 | await chrome.action.setIcon({ 350 | path: { 351 | 16: '/images/logo-red16.png', 352 | 32: '/images/logo-red32.png', 353 | 48: '/images/logo-red48.png', 354 | }, 355 | }) 356 | } else if (color === 'yellow') { 357 | console.debug('Setting Yellow Icon') 358 | await chrome.action.setIcon({ 359 | path: { 360 | 16: '/images/logo-yellow16.png', 361 | 32: '/images/logo-yellow32.png', 362 | 48: '/images/logo-yellow48.png', 363 | }, 364 | }) 365 | } else if (color === 'green') { 366 | console.debug('Setting Green Icon') 367 | await chrome.action.setIcon({ 368 | path: { 369 | 16: '/images/logo16.png', 370 | 32: '/images/logo32.png', 371 | 48: '/images/logo48.png', 372 | }, 373 | }) 374 | } else { 375 | console.warn('Unknown Color for setIcon:', color) 376 | } 377 | } 378 | 379 | /** 380 | * Create Context Menus 381 | * @function createContextMenus 382 | */ 383 | function createContextMenus() { 384 | if (!chrome.contextMenus) { 385 | return console.debug('Skipping: chrome.contextMenus') 386 | } 387 | console.debug('createContextMenus') 388 | chrome.contextMenus.removeAll() 389 | /** @type {Array[String[], String, String, String]} */ 390 | const contexts = [ 391 | // [['all'], 'showPanel', 'Open Panel'], 392 | // [['all'], 'separator'], 393 | [['all'], 'openOptions', 'Auto Auth Options'], 394 | ] 395 | contexts.forEach(addContext) 396 | } 397 | 398 | /** 399 | * Add Context from Array 400 | * @function addContext 401 | * @param {[[ContextType],String,String,String]} context 402 | */ 403 | function addContext(context) { 404 | try { 405 | console.debug('addContext:', context) 406 | if (context[1] === 'separator') { 407 | context[1] = Math.random().toString().substring(2, 7) 408 | context.push('separator', 'separator') 409 | } 410 | chrome.contextMenus.create({ 411 | contexts: context[0], 412 | id: context[1], 413 | title: context[2], 414 | type: context[3], 415 | }) 416 | } catch (e) { 417 | console.log(`%cError Adding Context: ${e.message}`, 'color: Red', e) 418 | } 419 | } 420 | 421 | /** 422 | * Set Default Options 423 | * @function setDefaultOptions 424 | * @param {Object} defaultOptions 425 | * @return {Promise>} 426 | */ 427 | async function setDefaultOptions(defaultOptions) { 428 | console.log('setDefaultOptions', defaultOptions) 429 | // let { sites } = await chrome.storage.sync.get(['sites']) 430 | // if (!sites) { 431 | // await chrome.storage.sync.set({ sites: {} }) 432 | // console.debug('Initialized Empty sync sites') 433 | // } 434 | const { session } = await chrome.storage.session.get(['session']) 435 | if (!session) { 436 | await chrome.storage.session.set({ session: {} }) 437 | console.debug('setDefaultOptions: Initialized Empty session') 438 | } 439 | let { options } = await chrome.storage.sync.get(['options']) 440 | options = options || {} 441 | let changed = false 442 | for (const [key, value] of Object.entries(defaultOptions)) { 443 | // console.log(`${key}: default: ${value} current: ${options[key]}`) 444 | if (options[key] === undefined) { 445 | changed = true 446 | options[key] = value 447 | console.log(`%cSet ${key}:`, 'color: LimeGreen', value) 448 | } 449 | } 450 | if (changed) { 451 | await chrome.storage.sync.set({ options }) 452 | console.log('changed:', options) 453 | } 454 | return options 455 | } 456 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Chrome Web Store Users](https://img.shields.io/chrome-web-store/users/gpoiggobidhogpmmlakahiaaegibnogm?logo=google&logoColor=white&label=users)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 2 | [![Mozilla Add-on Users](https://img.shields.io/amo/users/auto-auth?logo=mozilla&label=users)](https://addons.mozilla.org/addon/auto-auth) 3 | [![Chrome Web Store Rating](https://img.shields.io/chrome-web-store/rating/gpoiggobidhogpmmlakahiaaegibnogm?logo=google&logoColor=white)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 4 | [![Mozilla Add-on Rating](https://img.shields.io/amo/rating/auto-auth?logo=mozilla&logoColor=white)](https://addons.mozilla.org/addon/auto-auth) 5 | [![GitHub Repo Stars](https://img.shields.io/github/stars/cssnr/auto-auth?style=flat&logo=github&logoColor=white)](https://github.com/cssnr/auto-auth/stargazers) 6 | [![Chrome Web Store Version](https://img.shields.io/chrome-web-store/v/gpoiggobidhogpmmlakahiaaegibnogm?label=chrome&logo=googlechrome)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 7 | [![Mozilla Add-on Version](https://img.shields.io/amo/v/auto-auth?label=firefox&logo=firefox)](https://addons.mozilla.org/addon/auto-auth) 8 | [![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/auto-auth?logo=github&logoColor=white)](https://github.com/cssnr/auto-auth/releases/latest) 9 | [![Build](https://img.shields.io/github/actions/workflow/status/cssnr/auto-auth/build.yaml?logo=github&logoColor=white&label=build)](https://github.com/cssnr/auto-auth/actions/workflows/build.yaml) 10 | [![Test](https://img.shields.io/github/actions/workflow/status/cssnr/auto-auth/test.yaml?logo=github&logoColor=white&label=test)](https://github.com/cssnr/auto-auth/actions/workflows/test.yaml) 11 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cssnr_auto-auth&metric=alert_status&label=quality)](https://sonarcloud.io/summary/overall?id=cssnr_auto-auth) 12 | [![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/auto-auth?logo=github&logoColor=white&label=updated)](https://github.com/cssnr/auto-auth/graphs/commit-activity) 13 | [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/auto-auth?logo=htmx&logoColor=white)](https://github.com/cssnr/auto-auth) 14 | [![GitHub Repo Size](https://img.shields.io/github/repo-size/cssnr/auto-auth?logo=bookstack&logoColor=white&label=repo%20size)](https://github.com/cssnr/auto-auth) 15 | [![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=github&logoColor=white&label=org%20stars)](https://cssnr.github.io/) 16 | [![Discord](https://img.shields.io/discord/899171661457293343?logo=discord&logoColor=white&label=discord&color=7289da)](https://discord.gg/wXy6m2X8wY) 17 | [![Ko-fi](https://img.shields.io/badge/Ko--fi-72a5f2?logo=kofi&label=support)](https://ko-fi.com/cssnr) 18 | 19 | # Auto Auth 20 | 21 | Modern Chrome Web Extension and Firefox Browser Addon for Automatic Basic HTTP Authentication with many Options and 22 | Features. 23 | 24 | To take it for a test drive, [install](#Install) the addon and head over to: https://authenticationtest.com/HTTPAuth/ 25 | then enter the username `user` and password `pass` 26 | 27 | - [Install](#Install) 28 | - [Features](#Features) 29 | - [Upcoming Features](#Upcoming-Features) 30 | - [Known Issues](#Known-Issues) 31 | - [Configuration](#Configuration) 32 | - [Migration](#Migration) 33 | - [AutoAuth](#AutoAuth) 34 | - [Basic Authentication](#Basic-Authentication) 35 | - [Other or Manual](#Other-or-Manual) 36 | - [Security](#Security) 37 | - [Support](#Support) 38 | - [Development](#Development) 39 | - [Building](#Building) 40 | - [Contributing](#Contributing) 41 | 42 | ## Install 43 | 44 | - [Google Chrome Web Store](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 45 | - [Mozilla Firefox Add-ons](https://addons.mozilla.org/addon/auto-auth) 46 | 47 | [![Chrome](https://raw.githubusercontent.com/smashedr/logo-icons/master/browsers/chrome_48.png)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 48 | [![Firefox](https://raw.githubusercontent.com/smashedr/logo-icons/master/browsers/firefox_48.png)](https://addons.mozilla.org/addon/auto-auth) 49 | [![Edge](https://raw.githubusercontent.com/smashedr/logo-icons/master/browsers/edge_48.png)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 50 | [![Brave](https://raw.githubusercontent.com/smashedr/logo-icons/master/browsers/brave_48.png)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 51 | [![Opera](https://raw.githubusercontent.com/smashedr/logo-icons/master/browsers/opera_48.png)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 52 | [![Chromium](https://raw.githubusercontent.com/smashedr/logo-icons/master/browsers/chromium_48.png)](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 53 | 54 | All **Chromium** Based Browsers can install the extension from 55 | the [Chrome Web Store](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm). 56 | 57 | [![QR Code GitHub](https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/auto-auth/qr-firefox.png)](https://addons.mozilla.org/addon/auto-auth) 58 | 59 | ## Features 60 | 61 | - Save Logins for HTTP Basic Authentication 62 | - Automatically Login with Saved Credentials 63 | - Option to Ignore Specific Hosts 64 | - Notification on Invalid Credentials 65 | - View, Delete and Edit Saved Credentials 66 | - Option to Ignore Proxy Authentication 67 | - Option to Temporarily Disable 68 | - Ability to Import/Export Credentials 69 | - Toolbar Status for Enabled Hosts 70 | - Icon Colors for Extension Status 71 | 72 | ### Upcoming Features 73 | 74 | - Save Multiple Credentials for a Single Host 75 | - Manually Add Saved Credentials 76 | - Toggle to Match Any Port for Host 77 | 78 | Long-term Goals for Improved Security: 79 | 80 | - Add Optional Password Encryption Feature 81 | - Add a Sync Service for Cross-Browser Synchronization 82 | 83 | > [!TIP] 84 | > **Don't see your feature here?** 85 | > Request one on 86 | > the [Feature Request Discussion](https://github.com/cssnr/auto-auth/discussions/categories/feature-requests). 87 | 88 | ### Known Issues 89 | 90 | - Only allows saving 1 set of credentials per host. 91 | - Most browsers will offer to save passwords on login and edit. 92 | - Incognito and Private Browsing will not allow logging into new sites. 93 | - You must save the credentials first or add them manually. 94 | - A 401 response from a Service Worker is not properly intercepted: 95 | - Firefox: Shows a generic 401 page, use `Ctrl+F5` 96 | - Once credentials are saved, requests will work as normal. 97 | - Chrome: Shows a default credentials prompt, Cancel and press `Ctrl+F5` 98 | - This behavior may continue after saving credentials. 99 | 100 | > [!TIP] 101 | > **Don't see your issue here?** 102 | > Open one on the [Issues](https://github.com/cssnr/auto-auth/issues). 103 | 104 | ## Configuration 105 | 106 | You can pin the Addon by clicking the `Puzzle Piece`, find the Auto Auth icon, then; 107 | **Chrome,** click the `Pin` icon. 108 | **Firefox,** click the `Settings Wheel` and `Pin to Toolbar`. 109 | 110 | To open the options, click on the icon (from above) then click `Open Options`. 111 | You can also access `Options` through the right-click context menu (enabled by default). 112 | 113 | ## Migration 114 | 115 | Migration Guides from Other Web Extensions and manual import instructions. 116 | 117 | [AutoAuth](#AutoAuth) | [Basic Authentication](#Basic-Authentication) | [Other or Manual](#Other-or-Manual) 118 | 119 | ### AutoAuth 120 | 121 | Firefox: Migration from: [steffanschlein/AutoAuth](https://github.com/steffanschlein/AutoAuth) 122 | 123 | 1. Open Addons Management (about:addons) `Ctrl+Shift+A` 124 | 2. Find AutoAuth, click the 3 dots, then click Options 125 | 3. Open Developer Tools `Ctrl+Shift+I` and go to Console tab 126 | 4. Enter the following code: `await browser.storage.local.get()` 127 | 5. Right-click on the resulting output and choose `Copy Object` 128 | 6. Go to the Options Page (for this extension) and click `Import Text` 129 | 7. Paste the copied text into the textarea and click `Import` 130 | 131 | ### Basic Authentication 132 | 133 | Chrome: Migration 134 | from: [Basic Authentication](https://chromewebstore.google.com/detail/nanfgbiblbcagfodkfeinbbhijihckml) 135 | 136 | 1. Go To this URL: `chrome-extension://nanfgbiblbcagfodkfeinbbhijihckml/options.html` 137 | 2. Open Developer Tools `Ctrl+Shift+I` and go to Console tab 138 | 3. Enter the following code: `await chrome.storage.local.get()` 139 | 4. Right-click on the resulting output and choose `Copy Object` 140 | 5. Go to the Options Page (for this extension) and click `Import Text` 141 | 6. Paste the copied text into the textarea and click `Import` 142 | 143 | Note: Basic Authentication uses url match patterns vs hostnames. This import will attempt to parse the match pattern to 144 | a hostname; however, if the full hostname is not provided, may not import correctly. You can always edit the credentials 145 | manually or save new ones on the next login. 146 | 147 | ### Other or Manual 148 | 149 | To manually migrate from other data exports you need to convert the data into a compatible JSON format. 150 | You can do this yourself, or get ChatGPT to convert the data for you. Convert the data to this JSON format: 151 | 152 | ```json 153 | { 154 | "example.com": "username:password", 155 | "ignored.example.com": "ignored" 156 | } 157 | ``` 158 | 159 | To import the data, visit the extension's Options Page, click `Import Text` and paste the JSON text. 160 | 161 | You can also [request a migration](https://github.com/cssnr/auto-auth/discussions/categories/feature-requests) be added 162 | for your extension. If it is popular enough, it might get added. 163 | 164 | ## Security 165 | 166 | Since there is no API to manage or store credentials securely, usernames and passwords are stored in the web 167 | extension's [sync storage](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync). 168 | This will sync your credentials to all browsers you are logged into if sync is enabled for addons. Therefore, any 169 | computers you use a synced browser on will write the credentials to the file system in plain text. 170 | 171 | If there is enough popularity/requests for these features, there are a couple options to mitigate this: 172 | 173 | - Option to switch between sync and local storage to limit credentials to a single computer. 174 | - Option to encrypt credentials using a password that must be entered once every session. 175 | 176 | ## Support 177 | 178 | For help using the web extension, see: 179 | 180 | - Documentation: https://auto-auth.cssnr.com/docs/ 181 | - Q&A Discussion: https://github.com/cssnr/auto-auth/discussions/categories/q-a 182 | - Request a Feature: https://github.com/cssnr/auto-auth/discussions/categories/feature-requests 183 | 184 | If you are experiencing an issue/bug or getting unexpected results, you can: 185 | 186 | - Report an Issue: https://github.com/cssnr/auto-auth/issues 187 | - Chat with us on Discord: https://discord.gg/wXy6m2X8wY 188 | - Provide General Feedback: https://cssnr.github.io/feedback 189 | 190 | Logs can be found inspecting the page (Ctrl+Shift+I), clicking on the Console, and; 191 | Firefox: toggling Debug logs, Chrome: toggling Verbose from levels dropdown. 192 | 193 | To support this project, see the [Contributing](#Contributing) section at the bottom. 194 | 195 | # Development 196 | 197 | **Quick Start** 198 | 199 | First, clone (or download) this repository and change into the directory. 200 | 201 | Second, install the dependencies: 202 | 203 | ```shell 204 | npm install 205 | ``` 206 | 207 | Finally, to run Chrome or Firefox with web-ext, run one of the following: 208 | 209 | ```shell 210 | npm run chrome 211 | npm run firefox 212 | ``` 213 | 214 | Additionally, to Load Unpacked/Temporary Add-on make a `manifest.json` and run from the [src](src) folder, run one of 215 | the following: 216 | 217 | ```shell 218 | npm run manifest:chrome 219 | npm run manifest:firefox 220 | ``` 221 | 222 | Chrome: [https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world#load-unpacked](https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world#load-unpacked) 223 | Firefox: [https://extensionworkshop.com/documentation/develop/temporary-installation-in-firefox/](https://extensionworkshop.com/documentation/develop/temporary-installation-in-firefox/) 224 | 225 | For more information on 226 | web-ext, [read this documentation](https://extensionworkshop.com/documentation/develop/web-ext-command-reference/). 227 | To pass additional arguments to an `npm run` command, use `--`. 228 | Example: `npm run chrome -- --chromium-binary=...` 229 | 230 | ## Building 231 | 232 | Install the requirements and copy libraries into the `src/dist` directory by running `npm install`. 233 | See [gulpfile.js](gulpfile.js) for more information on `postinstall`. 234 | 235 | ```shell 236 | npm install 237 | ``` 238 | 239 | To create a `.zip` archive of the [src](src) directory for the desired browser run one of the following: 240 | 241 | ```shell 242 | npm run build 243 | npm run build:chrome 244 | npm run build:firefox 245 | ``` 246 | 247 | For more information on building, see the scripts section in the [package.json](package.json) file. 248 | 249 | ### Chrome Setup 250 | 251 | 1. Build or Download a [Release](https://github.com/cssnr/auto-auth/releases). 252 | 1. Unzip the archive, place the folder where it must remain and note its location for later. 253 | 1. Open Chrome, click the `3 dots` in the top right, click `Extensions`, click `Manage Extensions`. 254 | 1. In the top right, click `Developer Mode` then on the top left click `Load unpacked`. 255 | 1. Navigate to the folder you extracted in step #3 then click `Select Folder`. 256 | 257 | ### Firefox Setup 258 | 259 | 1. Build or Download a [Release](https://github.com/cssnr/auto-auth/releases). 260 | 1. Unzip the archive, place the folder where it must remain and note its location for later. 261 | 1. Go to `about:debugging#/runtime/this-firefox` and click `Load Temporary Add-on...` 262 | 1. Navigate to the folder you extracted earlier, select `manifest.json` then click `Select File`. 263 | 1. Optional: open `about:config` search for `extensions.webextensions.keepStorageOnUninstall` and set to `true`. 264 | 265 | If you need to test a restart, you must pack the addon. This only works in ESR, Development, or Nightly. 266 | You may also use an Unbranded 267 | Build: [https://wiki.mozilla.org/Add-ons/Extension_Signing#Unbranded_Builds](https://wiki.mozilla.org/Add-ons/Extension_Signing#Unbranded_Builds) 268 | 269 | 1. Run `npm run build:firefox` then use `web-ext-artifacts/{name}-firefox-{version}.zip`. 270 | 1. Open `about:config` search for `xpinstall.signatures.required` and set to `false`. 271 | 1. Open `about:addons` and drag the zip file to the page or choose Install from File from the Settings wheel. 272 | 273 | # Contributing 274 | 275 | Please consider making a donation to support the development of this project 276 | and [additional](https://cssnr.com/) open source projects. 277 | 278 | [![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cssnr) 279 | 280 | Additionally, you can give a 5-star rating 281 | on [Google](https://chromewebstore.google.com/detail/auto-auth/gpoiggobidhogpmmlakahiaaegibnogm) 282 | or [Mozilla](https://addons.mozilla.org/addon/auto-auth) and star this project on GitHub. 283 | 284 | Other Web Extensions I have created and published: 285 | 286 | - [Link Extractor](https://github.com/cssnr/link-extractor?tab=readme-ov-file#readme) 287 | - [Open Links in New Tab](https://github.com/cssnr/open-links-in-new-tab?tab=readme-ov-file#readme) 288 | - [Auto Auth](https://github.com/cssnr/auto-auth?tab=readme-ov-file#readme) 289 | - [Cache Cleaner](https://github.com/cssnr/cache-cleaner?tab=readme-ov-file#readme) 290 | - [HLS Video Downloader](https://github.com/cssnr/hls-video-downloader?tab=readme-ov-file#readme) 291 | - [Zipline Extension](https://github.com/cssnr/zipline-extension?tab=readme-ov-file#readme) 292 | - [Obtainium Extension](https://github.com/cssnr/obtainium-extension?tab=readme-ov-file#readme) 293 | - [SMWC Web Extension](https://github.com/cssnr/smwc-web-extension?tab=readme-ov-file#readme) 294 | - [PlayDrift Extension](https://github.com/cssnr/playdrift-extension?tab=readme-ov-file#readme) 295 | - [ASN Plus](https://github.com/cssnr/asn-plus?tab=readme-ov-file#readme) 296 | - [Aviation Tools](https://github.com/cssnr/aviation-tools?tab=readme-ov-file#readme) 297 | - [Text Formatter](https://github.com/cssnr/text-formatter?tab=readme-ov-file#readme) 298 | 299 | For a full list of current projects visit: [https://cssnr.github.io/](https://cssnr.github.io/) 300 | -------------------------------------------------------------------------------- /src/html/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Auto Auth Options 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 | Auto Auth 20 |
21 | 22 | Auto Auth 23 | 24 | v 25 |
26 |
27 | 28 |
29 |
Keyboard Shortcuts
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
Keyboard Shortcuts
DescriptionShortcut
Unknown
43 |
44 | Manage Keyboard Shortcuts: 45 | 46 | https://mzl.la/3Qwp5QQ 47 | chrome://extensions/shortcuts 48 |
49 | 50 |
51 |
Extension Options
52 |
53 | 54 |
55 | 59 |

More Information on Permissions

60 | 63 |
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
72 |
73 | 75 | 76 | 77 |
78 | 81 |
82 | 83 | 84 | 85 |
86 |
87 | 88 | 89 | 90 |
91 |
92 | 93 | 94 | 95 |
96 |
97 | 98 | 99 | 100 |
101 |
102 | 103 | 104 | 105 |
106 | 107 |
108 | Auth Page Background 109 | 110 | 111 | 112 |
113 | 114 |
115 |
116 | 117 | 120 |
121 |
122 | 123 | 126 |
127 |
128 | 129 | 132 |
133 |
134 | 135 |
136 |
137 | 138 | 139 | 141 |
142 |
143 | 144 | 145 | 147 |
148 |
149 | 150 |
151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 |
165 |
Credentials
166 |
167 | 168 |
Saved Credentials
169 | 170 |
171 | 172 | Export 173 | 174 | 175 | 176 | Import File 177 | 178 | 179 | Import Text 180 |
181 | 182 | 184 | 185 | 186 | 187 | 188 | 191 | 192 | 193 | 196 | 197 | 198 |
Saved Credentials
189 | 190 | HostUsername 194 | 195 |
199 | 200 |
Ignored Hosts
201 | 202 | 203 | 204 | 205 | 208 | 209 | 210 | 211 |
Ignored Hosts
206 | 207 | Host
212 | 213 |

214 | Copy Support Information for issue reporting. 215 |

216 | 217 |
218 | 219 |
220 | Home Page 222 | 223 | Migration Guide 225 | 226 | Open Issue 228 |
229 |
230 |
231 | 232 | 252 | 253 | 331 | 332 | 362 | 363 | 366 | 367 |
368 |
369 |
370 | 371 |
372 | 375 | 376 | 377 | 378 | 379 | 380 |
381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | -------------------------------------------------------------------------------- /src/js/options.js: -------------------------------------------------------------------------------- 1 | // JS for options.html 2 | 3 | import { 4 | Hosts, 5 | checkPerms, 6 | copyInput, 7 | grantPerms, 8 | showHidePassword, 9 | linkClick, 10 | onAdded, 11 | onRemoved, 12 | revokePerms, 13 | saveOptions, 14 | showToast, 15 | textFileDownload, 16 | updateManifest, 17 | updateBrowser, 18 | updateOptions, 19 | } from './export.js' 20 | 21 | chrome.storage.onChanged.addListener(onChanged) 22 | chrome.permissions.onAdded.addListener(onAdded) 23 | chrome.permissions.onRemoved.addListener(onRemoved) 24 | 25 | document.addEventListener('DOMContentLoaded', initOptions) 26 | // document.getElementById('add-host').addEventListener('submit', addHost) 27 | document.getElementById('copy-support').addEventListener('click', copySupport) 28 | const editForm = document.getElementById('edit-form') 29 | editForm.addEventListener('submit', editSubmit) 30 | editForm.addEventListener('change', editChange) 31 | 32 | const hostsInput = document.getElementById('hosts-input') 33 | hostsInput.addEventListener('change', hostsInputChange) 34 | document.getElementById('add-hosts').addEventListener('click', editClick) 35 | document.getElementById('export-hosts').addEventListener('click', exportHosts) 36 | document.getElementById('import-file').addEventListener('click', importHosts) 37 | document.getElementById('import-text').addEventListener('click', importText) 38 | 39 | document 40 | .querySelectorAll('.revoke-permissions') 41 | .forEach((el) => el.addEventListener('click', revokePerms)) 42 | document 43 | .querySelectorAll('.grant-permissions') 44 | .forEach((el) => el.addEventListener('click', grantPerms)) 45 | document 46 | .querySelectorAll('a[href]') 47 | .forEach((el) => el.addEventListener('click', linkClick)) 48 | document 49 | .querySelectorAll('[data-show-hide]') 50 | .forEach((el) => el.addEventListener('click', showHidePassword)) 51 | document 52 | .querySelectorAll('[data-copy-input]') 53 | .forEach((el) => el.addEventListener('click', copyInput)) 54 | document 55 | .querySelectorAll('#options-form input') 56 | .forEach((el) => el.addEventListener('change', saveOptions)) 57 | document 58 | .getElementById('options-form') 59 | .addEventListener('submit', (e) => e.preventDefault()) 60 | document 61 | .querySelectorAll('[data-bs-toggle="tooltip"]') 62 | .forEach((el) => new bootstrap.Tooltip(el)) 63 | document 64 | .getElementsByName('radioBackground') 65 | .forEach((el) => el.addEventListener('change', backgroundChange)) 66 | 67 | document.getElementById('chrome-shortcuts').addEventListener('click', () => { 68 | // noinspection JSIgnoredPromiseFromCall 69 | chrome.tabs.update({ url: 'chrome://extensions/shortcuts' }) 70 | }) 71 | 72 | const trashCan = document.querySelector('#clones > .fa-trash-can') 73 | const faPen = document.querySelector('#clones > .fa-pen-to-square') 74 | 75 | const bgPictureInput = document.getElementById('bgPictureInput') 76 | const bgVideoInput = document.getElementById('bgVideoInput') 77 | 78 | const editHostname = document.getElementById('hostname') 79 | const editUsername = document.getElementById('username') 80 | const editPassword = document.getElementById('password') 81 | 82 | const confirmDelete = document.getElementById('confirm-delete') 83 | const confirmDeleteHost = document.getElementById('delete-host') 84 | const deleteModal = new bootstrap.Modal('#delete-modal') 85 | confirmDelete.addEventListener('click', deleteHost) 86 | 87 | const editModalEl = document.getElementById('edit-modal') 88 | const editModalAlert = document.getElementById('edit-modal-alert') 89 | const editModal = new bootstrap.Modal(editModalEl) 90 | editModalEl.addEventListener('shown.bs.modal', () => { 91 | if (editForm.dataset.action === 'add') { 92 | editHostname.focus() 93 | } else { 94 | editUsername.focus() 95 | } 96 | }) 97 | editModalEl.addEventListener('hide.bs.modal', () => { 98 | editModal._config.backdrop = true 99 | editModalAlert.classList.add('d-none') 100 | }) 101 | editModalEl.addEventListener('hidePrevented.bs.modal', () => { 102 | console.log('Changes Detected!') 103 | editModalAlert.classList.remove('d-none') 104 | }) 105 | 106 | const importModalEl = document.getElementById('import-modal') 107 | const importModal = new bootstrap.Modal(importModalEl) 108 | const importTextarea = document.getElementById('import-textarea') 109 | document.getElementById('clear-import').addEventListener('click', () => { 110 | importTextarea.value = '' 111 | importTextarea.focus() 112 | }) 113 | importModalEl.addEventListener('shown.bs.modal', () => { 114 | importTextarea.focus() 115 | }) 116 | 117 | $('.form-control').on('change input', function () { 118 | $(this).removeClass('is-invalid') 119 | }) 120 | 121 | /** 122 | * Initialize Options 123 | * @function initOptions 124 | */ 125 | async function initOptions() { 126 | console.debug('initOptions') 127 | // noinspection ES6MissingAwait 128 | updateManifest() 129 | // noinspection ES6MissingAwait 130 | updateBrowser() 131 | // noinspection ES6MissingAwait 132 | setShortcuts('#keyboard-shortcuts', true) 133 | checkPerms().then((hasPerms) => { 134 | if (!hasPerms) console.log('%cMissing Host Permissions', 'color: Red') 135 | }) 136 | chrome.storage.sync.get(['options']).then((items) => { 137 | updateOptions(items.options) 138 | backgroundChange(items.options.radioBackground) 139 | }) 140 | 141 | const hosts = await Hosts.all() 142 | // console.debug('hosts:', hosts) 143 | updateTable(hosts) 144 | } 145 | 146 | /** 147 | * Update Popup Table with Data 148 | * @function updateTable 149 | * @param {Object} data 150 | */ 151 | function updateTable(data) { 152 | const hostsBody = document.querySelector('#hosts-table > tbody') 153 | hostsBody.innerHTML = '' 154 | const ignoredBody = document.querySelector('#ignored-table > tbody') 155 | ignoredBody.innerHTML = '' 156 | 157 | for (const [key, value] of Object.entries(data)) { 158 | const ignored = value === 'ignored' 159 | const row = ignored ? ignoredBody.insertRow() : hostsBody.insertRow() 160 | const username = value.split(':')[0] 161 | // console.debug('username:', username) 162 | 163 | const deleteBtn = document.createElement('a') 164 | const trash = trashCan.cloneNode(true) 165 | deleteBtn.appendChild(trash) 166 | deleteBtn.title = 'Delete' 167 | deleteBtn.dataset.value = key 168 | deleteBtn.classList.add('link-danger') 169 | deleteBtn.setAttribute('role', 'button') 170 | deleteBtn.addEventListener('click', deleteHost) 171 | const cell1 = row.insertCell() 172 | cell1.classList.add('text-center') 173 | cell1.appendChild(deleteBtn) 174 | 175 | const hostLink = document.createElement('a') 176 | hostLink.text = key 177 | hostLink.title = key 178 | hostLink.href = `https://${key}` 179 | hostLink.target = '_blank' 180 | hostLink.setAttribute('role', 'button') 181 | const cell2 = row.insertCell() 182 | cell2.classList.add('text-break') 183 | cell2.appendChild(hostLink) 184 | 185 | if (ignored) { 186 | continue 187 | } 188 | 189 | const user = document.createTextNode(username) 190 | const cell3 = row.insertCell() 191 | cell3.appendChild(user) 192 | cell3.classList.add('text-break', 'd-none', 'd-sm-table-cell') 193 | 194 | const editBtn = document.createElement('a') 195 | const edit = faPen.cloneNode(true) 196 | editBtn.appendChild(edit) 197 | editBtn.title = 'Edit' 198 | editBtn.dataset.value = key 199 | editBtn.classList.add('link-warning') 200 | editBtn.setAttribute('role', 'button') 201 | editBtn.addEventListener('click', editClick) 202 | const cell4 = row.insertCell() 203 | cell4.classList.add('text-center') 204 | cell4.appendChild(editBtn) 205 | } 206 | } 207 | 208 | /** 209 | * Delete Host 210 | * @function deleteHost 211 | * @param {MouseEvent} event 212 | */ 213 | async function deleteHost(event) { 214 | console.debug('deleteHost:', event) 215 | try { 216 | const host = event.currentTarget?.dataset?.value 217 | console.debug('host:', host) 218 | const confirm = event.currentTarget?.id !== 'confirm-delete' 219 | const { options } = await chrome.storage.sync.get(['options']) 220 | if (options.confirmDelete && !!confirm) { 221 | console.debug('Show Delete Modal') 222 | confirmDelete.dataset.value = host 223 | confirmDeleteHost.textContent = host 224 | deleteModal.show() 225 | return 226 | } 227 | await Hosts.delete(host) 228 | deleteModal.hide() 229 | showToast(`Removed: ${host}`) 230 | } catch (e) { 231 | showToast(`Delete Error: ${e.message}`, 'danger') 232 | } 233 | } 234 | 235 | /** 236 | * Edit/Add Host Click Callback 237 | * @function editClick 238 | * @param {MouseEvent} event 239 | */ 240 | async function editClick(event) { 241 | console.debug('editClick:', event) 242 | const target = event.currentTarget 243 | const inputs = editModalEl.querySelectorAll('input') 244 | if (target.dataset.action === 'add') { 245 | // Process Add 246 | console.debug('%c Add Host editClick', 'color: Lime') 247 | document.getElementById('edit-modal-label').textContent = 'Add Host' 248 | editForm.dataset.action = 'add' 249 | inputs.forEach((el) => { 250 | el.classList.remove('is-invalid') 251 | el.value = '' 252 | }) 253 | editModal.show() 254 | return 255 | } 256 | // Process Edit 257 | document.getElementById('edit-modal-label').textContent = 'Edit Host' 258 | editForm.dataset.action = 'edit' 259 | inputs.forEach((el) => el.classList.remove('is-invalid')) 260 | const host = target?.dataset?.value 261 | console.debug('host:', host) 262 | const creds = await Hosts.get(host) 263 | const [username, password] = creds.split(':') 264 | editHostname.value = host 265 | editHostname.dataset.original = host 266 | editUsername.value = username 267 | editUsername.dataset.original = username 268 | editPassword.value = password 269 | editPassword.dataset.original = password 270 | editPassword.type = 'password' 271 | editModal.show() 272 | } 273 | 274 | /** 275 | * Edit Host Submit Callback 276 | * @function editSubmit 277 | * @param {SubmitEvent} event 278 | */ 279 | async function editSubmit(event) { 280 | console.debug('editSubmit:', event) 281 | const target = event.currentTarget 282 | event.preventDefault() 283 | event.stopPropagation() 284 | if (target.dataset.action === 'add') { 285 | console.debug('%c Add Host editSubmit:', 'color: Lime') 286 | await addHost(event) 287 | return 288 | } 289 | try { 290 | const hostname = getHost(editHostname.value) 291 | const username = editUsername.value 292 | const password = editPassword.value 293 | // console.debug('hostname ,username, password:', hostname, username, password) 294 | if ( 295 | hostname === editHostname.dataset.original && 296 | username === editUsername.dataset.original && 297 | password === editPassword.dataset.original 298 | ) { 299 | editModal.hide() 300 | return showToast('No Changes Detected', 'warning') 301 | } 302 | // TODO: Validate Hostname/Username/Password 303 | // const { sites } = await chrome.storage.sync.get(['sites']) 304 | // if (hostname !== editHostname.dataset.original) { 305 | // delete sites[editHostname.dataset.original] 306 | // } 307 | // sites[hostname] = `${username}:${password}` 308 | // await chrome.storage.sync.set({ sites }) 309 | await Hosts.edit( 310 | editHostname.dataset.original, 311 | hostname, 312 | `${username}:${password}` 313 | ) 314 | editModal.hide() 315 | showToast(`Updated Host: ${hostname}`, 'success') 316 | } catch (e) { 317 | showToast(`Error saving credentials: ${e.message}`, 'danger') 318 | } 319 | } 320 | 321 | /** 322 | * Add Host Callback 323 | * @function addHost 324 | * @param {SubmitEvent} event 325 | */ 326 | async function addHost(event) { 327 | console.debug('addHost:', event) 328 | event.preventDefault() 329 | /** @type {HTMLInputElement} */ 330 | const input = event.target.elements['hostname'] 331 | console.debug('input:', input) 332 | let value = input.value 333 | console.debug('value:', value) 334 | if (!value.includes('://')) { 335 | value = `https://${value}` 336 | } 337 | let url 338 | try { 339 | url = new URL(value) 340 | } catch (e) { 341 | showToast(e.message, 'danger') 342 | input.focus() 343 | input.select() 344 | return console.info(e) 345 | } 346 | console.log('url:', url) 347 | // const { sites } = await chrome.storage.sync.get(['sites']) 348 | const existing = await Hosts.get(url.hostname) 349 | console.debug('existing:', existing) 350 | if (existing) { 351 | // showToast(`Host Exists: ${url.hostname}`, 'warning') 352 | document.getElementById('hostnameValidation').textContent = 353 | 'Hostname Already Exist!' 354 | input.focus() 355 | input.select() 356 | input.classList.add('is-invalid') 357 | return console.debug('Existing Host: url:', url) 358 | } 359 | /** @type {HTMLInputElement} */ 360 | const usernameEl = event.target.elements['username'] 361 | console.log('username:', usernameEl.value) 362 | if (!usernameEl.value) { 363 | document.getElementById('usernameValidation').textContent = 364 | 'Username Required!' 365 | usernameEl.focus() 366 | usernameEl.classList.add('is-invalid') 367 | return console.debug('No username') 368 | } 369 | /** @type {HTMLInputElement} */ 370 | const passwordEl = event.target.elements['password'] 371 | console.log('password:', passwordEl.value) 372 | if (!passwordEl.value) { 373 | document.getElementById('passwordValidation').textContent = 374 | 'Password Required!' 375 | passwordEl.focus() 376 | passwordEl.classList.add('is-invalid') 377 | return console.debug('No password') 378 | } 379 | console.log(`Adding Host: ${url.hostname}`, url) 380 | await Hosts.set(url.host, `${usernameEl.value}:${passwordEl.value}`) 381 | showToast(`Added Host: ${url.hostname}`) 382 | editModal.hide() 383 | } 384 | 385 | /** 386 | * @function getHost 387 | * @param {String} hostname 388 | * @return {String} 389 | */ 390 | function getHost(hostname) { 391 | let host = hostname.toLowerCase().trim() 392 | host = host.includes('://') ? host : 'https://' + host 393 | console.debug('host:', host) 394 | const url = new URL(host) 395 | console.debug('url.host:', url.host) 396 | if (!url.host) { 397 | throw new Error(`Invalid Hostname: ${hostname}`) 398 | } 399 | return url.host 400 | } 401 | 402 | /** 403 | * Edit Host Change Callback 404 | * @function editChange 405 | * @param {SubmitEvent} event 406 | */ 407 | async function editChange(event) { 408 | console.debug('editChange:', event) 409 | editModal._config.backdrop = 'static' 410 | } 411 | 412 | /** 413 | * Export Hosts Click Callback 414 | * @function exportHosts 415 | * @param {MouseEvent} event 416 | */ 417 | async function exportHosts(event) { 418 | console.debug('exportHosts:', event) 419 | event.preventDefault() 420 | // const { sites } = await chrome.storage.sync.get(['sites']) 421 | // console.debug('sites:', sites) 422 | 423 | const hosts = await Hosts.all() 424 | // console.debug('hosts:', hosts) 425 | if (Object.keys(hosts).length === 0) { 426 | return showToast('No Credentials to Export', 'warning') 427 | } 428 | const json = JSON.stringify(hosts, null, 2) 429 | textFileDownload('auto-auth-secrets.txt', json) 430 | } 431 | 432 | /** 433 | * Import Hosts Click Callback 434 | * @function importHosts 435 | * @param {MouseEvent} event 436 | */ 437 | async function importHosts(event) { 438 | console.debug('importHosts:', event) 439 | event.preventDefault() 440 | hostsInput.click() 441 | } 442 | 443 | /** 444 | * Import Text Click Callback 445 | * @function importText 446 | * @param {MouseEvent} event 447 | */ 448 | async function importText(event) { 449 | console.debug('importText:', event) 450 | event.preventDefault() 451 | if (!importTextarea.value) { 452 | importTextarea.focus() 453 | return 454 | } 455 | try { 456 | const data = JSON.parse(importTextarea.value) 457 | // console.debug('data:', data) 458 | await importCredentials(data) 459 | importModal.hide() 460 | importTextarea.value = '' 461 | } catch (e) { 462 | console.debug('Import Error:', e) 463 | importModalEl.querySelector('.invalid-feedback').textContent = 464 | `Import Error: ${e.message}` 465 | importTextarea.classList.add('is-invalid') 466 | // showToast(`Import Error: ${e.message}`, 'danger') 467 | } 468 | } 469 | 470 | /** 471 | * Hosts Input Change Callback 472 | * @function hostsInputChange 473 | * @param {InputEvent} event 474 | */ 475 | async function hostsInputChange(event) { 476 | console.debug('hostsInputChange:', event, hostsInput) 477 | event.preventDefault() 478 | try { 479 | const file = event.target.files.item(0) 480 | const text = await file.text() 481 | const data = JSON.parse(text) 482 | // console.debug('data:', data) 483 | await importCredentials(data) 484 | } catch (e) { 485 | console.log('Import error:', e) 486 | showToast(`Import Error: ${e.message}`, 'warning') 487 | } 488 | } 489 | 490 | /** 491 | * Import Credentials 492 | * @function importCredentials 493 | * @param {Object} data 494 | */ 495 | async function importCredentials(data) { 496 | console.debug('importCredentials') 497 | const hosts = {} 498 | let count = 0 499 | let total 500 | if ('credentialsArray' in data) { 501 | // Basic Authentication (nanfgbiblbcagfodkfeinbbhijihckml) 502 | total = data.credentialsArray.length 503 | for (const item of data.credentialsArray) { 504 | try { 505 | // console.debug('item:', item) 506 | const key = getHost(item.url) 507 | hosts[key] = `${item.login}:${item.password}` 508 | count += 1 509 | } catch (e) { 510 | console.log(`Error processing item:`, 'color: Red', item, e) 511 | } 512 | } 513 | } else { 514 | total = Object.keys(data).length 515 | for (const [key, value] of Object.entries(data)) { 516 | // console.debug(`${key}:`, value) 517 | try { 518 | if (typeof value === 'object') { 519 | // AutoAuth (steffanschlein) 520 | const { username, password } = value 521 | if (!username || !password) { 522 | console.debug(`${key}: missing username or password`) 523 | continue 524 | } 525 | hosts[key] = `${username}:${password}` 526 | } else if (typeof value === 'string') { 527 | // Auto Auth (this extension) 528 | const [username, password] = value.split(':') 529 | if (value !== 'ignored' && (!username || !password)) { 530 | console.debug(`${key}: missing username or password`) 531 | continue 532 | } 533 | hosts[key] = value 534 | } 535 | count += 1 536 | } catch (e) { 537 | console.log(`Error processing: ${key}`, 'color: Red', e) 538 | } 539 | } 540 | } 541 | // console.debug('hosts:', hosts) 542 | await Hosts.update(hosts) 543 | const type = count ? 'success' : 'warning' 544 | showToast(`Imported/Updated ${count}/${total} Hosts.`, type) 545 | } 546 | 547 | /** 548 | * Auth Background Change Callback 549 | * @function backgroundChange 550 | * @param {String|InputEvent} event 551 | */ 552 | function backgroundChange(event) { 553 | console.debug('backgroundChange:', event) 554 | const id = typeof event === 'string' ? event : event?.target?.id 555 | console.debug('id:', id) 556 | if (id === 'bgPicture') { 557 | bgPictureInput.classList.remove('d-none') 558 | bgVideoInput.classList.add('d-none') 559 | } else if (id === 'bgVideo') { 560 | bgPictureInput.classList.add('d-none') 561 | bgVideoInput.classList.remove('d-none') 562 | } else { 563 | bgPictureInput.classList.add('d-none') 564 | bgVideoInput.classList.add('d-none') 565 | } 566 | } 567 | 568 | /** 569 | * On Changed Callback 570 | * @function onChanged 571 | * @param {Object} changes 572 | * @param {String} namespace 573 | */ 574 | async function onChanged(changes, namespace) { 575 | // console.debug('onChanged:', changes, namespace) 576 | if (namespace === 'sync') { 577 | if ('options' in changes) { 578 | updateOptions(changes.options.newValue) 579 | } else { 580 | const hosts = await Hosts.all() 581 | // console.debug('hosts:', hosts) 582 | updateTable(hosts) 583 | } 584 | } 585 | // for (const [key, { newValue }] of Object.entries(changes)) { 586 | // if (namespace === 'sync') { 587 | // if (key === 'options') { 588 | // updateOptions(newValue) 589 | // } else { 590 | // const hosts = await Hosts.all() 591 | // console.debug('hosts:', hosts) 592 | // updateTable(hosts) 593 | // } 594 | // } 595 | // } 596 | } 597 | 598 | /** 599 | * Set Keyboard Shortcuts 600 | * @function setShortcuts 601 | * @param {String} [selector] 602 | * @param {Boolean} [action] 603 | */ 604 | async function setShortcuts(selector = '#keyboard-shortcuts', action = false) { 605 | if (!chrome.commands) { 606 | return console.debug('Skipping: chrome.commands') 607 | } 608 | const table = document.querySelector(selector) 609 | if (!table) { 610 | return console.warn(`${selector} table not found`) 611 | } 612 | table.classList.remove('d-none') 613 | const tbody = table.querySelector('tbody') 614 | const source = table.querySelector('tfoot > tr').cloneNode(true) 615 | const commands = await chrome.commands.getAll() 616 | for (const command of commands) { 617 | try { 618 | // console.debug('command:', command) 619 | const row = source.cloneNode(true) 620 | let description = command.description 621 | // Note: Chrome does not parse the description for _execute_action in manifest.json 622 | if (!description && command.name === '_execute_action') { 623 | description = 'Show Popup Action' 624 | } 625 | row.querySelector('.description').textContent = description 626 | row.querySelector('kbd').textContent = command.shortcut || 'Not Set' 627 | tbody.appendChild(row) 628 | } catch (e) { 629 | console.warn('Error adding command:', command, e) 630 | } 631 | } 632 | if (action) { 633 | try { 634 | const userSettings = await chrome.action.getUserSettings() 635 | const row = source.cloneNode(true) 636 | row.querySelector('i').className = 'fa-solid fa-puzzle-piece me-1' 637 | row.querySelector('.description').textContent = 638 | 'Toolbar Icon Pinned' 639 | row.querySelector('kbd').textContent = userSettings.isOnToolbar 640 | ? 'Yes' 641 | : 'No' 642 | tbody.appendChild(row) 643 | } catch (e) { 644 | console.log('Error adding pinned setting:', e) 645 | } 646 | } 647 | } 648 | 649 | /** 650 | * Copy Support/Debugging Information 651 | * @function copySupport 652 | * @param {MouseEvent} event 653 | */ 654 | async function copySupport(event) { 655 | console.debug('copySupport:', event) 656 | event.preventDefault() 657 | const manifest = chrome.runtime.getManifest() 658 | const permissions = await chrome.permissions.getAll() 659 | const { options } = await chrome.storage.sync.get(['options']) 660 | const userSettings = await chrome.action.getUserSettings() 661 | const result = [ 662 | `${manifest.name} - ${manifest.version}`, 663 | navigator.userAgent, 664 | `permissions.origins: ${JSON.stringify(permissions.origins)}`, 665 | `options: ${JSON.stringify(options)}`, 666 | `pinned: ${userSettings.isOnToolbar ? 'yes' : 'no'}`, 667 | ] 668 | await navigator.clipboard.writeText(result.join('\n')) 669 | showToast('Support Information Copied.', 'success') 670 | } 671 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------