const webpack = require('webpack'), path = require('path'), {CleanWebpackPlugin} = require('clean-webpack-plugin'), CopyWebpackPlugin = require('copy-webpack-plugin'), WebpackExtensionManifestPlugin = require('webpack-extension-manifest-plugin'); const T = { CHROME : 'chrome', FIREFOX: 'firefox', }; // TODO will be conditional on T.CHROME at some point const v3 = false const env = { TARGET : process.env.TARGET, RELEASE: process.env.RELEASE, PUBLISH: process.env.PUBLISH, } const ext_id = process.env.EXT_ID const pkg = require('./package.json'); const baseManifest = require('./src/manifest.json'); const release = env.RELEASE == 'YES' ? true : false; const publish = env.PUBLISH == 'YES' ? true : false; const dev = !release; // meh. maybe make up my mind? const target = env.TARGET; const name = "grasp" + (dev ? ' [dev]' : ''); // ugh. declarative formats are shit. // 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}+C`, "mac": `Command+${modifier}+C`, }, } } 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", } if (target == T.FIREFOX) { action['browser_style'] = true } 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 = [ "storage", "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 = [ "default-src 'self'", "connect-src " + endpoints('*:*').join(' '), // FFS, otherwise