diff --git a/README.md b/README.md index 833ba8c..051bed6 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,6 @@ In addition: - \+ using a bookmarklet, hence browser-agnostic - \+ capable of on the fly HTML to org-mode markup conversion -# Requirements -No third party dependencies! Just `python3`. - # Potential improvements * see [todos](./TODO.org) @@ -96,13 +93,11 @@ You need `npm` for building the extension. After that you can find the extension in `dist` directory and 'Load unpacked** if necessary. There is also Flow and Eslint set up. ## testing and linting -Check [CI config](./.circleci/config.yml) to figure out all the checks I'm doing. - -The only test(s) that don't run on CI at the moment (e.g. due to lack of X server) are marked with `@skip_if_ci`. You can run them manually though. +Check [CI config](./.github/workflows/main.yml) to figure out all the checks I'm doing. -Extra tests (not integrated in CI yet): +There are some end2end tests which check both web extension and the browser, but require GUI, so they can't run on github actions. You can run them manually though. -- `scripts/test_with_browser.py` +- `pytest -s --pyargs tests.test_end2end` ## publishing diff --git a/extension/babel.config.js b/extension/babel.config.cjs similarity index 100% rename from extension/babel.config.js rename to extension/babel.config.cjs diff --git a/extension/eslint.config.js b/extension/eslint.config.js index 8c32353..3d1219e 100644 --- a/extension/eslint.config.js +++ b/extension/eslint.config.js @@ -1,11 +1,10 @@ // @ts-check +import globals from 'globals' +import eslint from '@eslint/js' +import tseslint from 'typescript-eslint' -const globals = require('globals') -const eslint = require('@eslint/js') -const tseslint = require('typescript-eslint') - -module.exports = tseslint.config( +export default tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, // TODO recommendedTypeChecked?? { diff --git a/extension/generate_manifest.js b/extension/generate_manifest.js new file mode 100644 index 0000000..ae2d0ea --- /dev/null +++ b/extension/generate_manifest.js @@ -0,0 +1,180 @@ +import assert from 'assert' + +import pkg from './package.json' with { type: "json" } + +const T = { + CHROME : 'chrome', + FIREFOX: 'firefox', +} + + +// ugh. declarative formats are shit. +export function generateManifest({ + target, // str + version, // str + release, // bool + ext_id // str +} = {}) { + assert(target) + assert(version) + assert(release !== null) + assert(ext_id) + + const v3 = version == '3' + + // Firefox wouldn't let you rebind its default shortcuts most of which use Shift + // On the other hand, Chrome wouldn't let you use Alt + const modifier = target === T.CHROME ? 'Shift' : 'Alt' + + const action_name = v3 ? 'action' : 'browser_action' + + const commands = { + "capture-simple": { + "description": "Quick capture: url, title and selection", + "suggested_key": { + "default": `Ctrl+${modifier}+H`, + "mac": `Command+${modifier}+H`, + }, + }, + } + + commands[`_execute_${action_name}`] = { + "description": "Capture page, with extra information", + "suggested_key": { + "default": `Ctrl+${modifier}+Y`, + "mac": `Command+${modifier}+Y`, + }, + } + + + const action = { + "default_icon": "img/unicorn.png", + "default_popup": "popup.html", + "default_title": "Capture page, with extra information", + } + + + const endpoints = (domain) => [ + "http://" + domain + "/capture", + "https://" + domain + "/capture", + ] + + + // prepare for manifest v3 + const host_permissions = endpoints('localhost') + const optional_host_permissions = endpoints('*') + + + // TODO make permissions literate + const permissions = [ + // for keeping extension settings + "storage", + + // for showing notification about successful capture or errors + "notifications", + + // need to query active tab and get its url/title + "activeTab", + ] + + + const optional_permissions = [] + + if (target === T.FIREFOX || v3) { + // chrome v2 doesn't support scripting api + // code has a fallback just for that + // (needed to get selected text) + permissions.push("scripting") + } + + + const content_security_policy = [ + "script-src 'self'", // this must be specified when overriding, otherwise it complains + /// also this works, but it seems that default-src somehow shadows style-src??? + // "default-src 'self'", + // "style-src 'unsafe-inline'", // FFS, otherwise