diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 63a947b..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@vue/app"] -} diff --git a/.eslintrc.js b/.eslintrc.js index 3b8b68b..7972d6a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,10 +1,19 @@ module.exports = { - parser: 'vue-eslint-parser', + // parser: 'eslint-plugin-vue', + extends: ['eslint:recommended', 'plugin:prettier/recommended'], plugins: ['prettier', 'vue'], + env: { + browser: true, + node: true, + }, parserOptions: { - parser: 'babel-eslint' + ecmaVersion: 6, + sourceType: 'module', + ecmaFeatures: { + module: true, + }, + }, + rules: { + 'no-unused-vars': ['off'], }, - env: { - browser: true - } }; diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..d0612ad --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run pre-commit diff --git a/.prettierrc b/.prettierrc index 3092d2b..7105208 100644 --- a/.prettierrc +++ b/.prettierrc @@ -7,7 +7,7 @@ } }, { - "files": ["*.js", "*.vue"], + "files": "*.{vue,ts,js}", "options": { "singleQuote": true } diff --git a/.travis.yml b/.travis.yml index 763b324..90c6ecc 100755 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: node_js node_js: node cache: - directories: node_modules + directories: + - node_modules -script: - - yarn release +script: npm install diff --git a/CHANGELOG.md b/CHANGELOG.md index b8924da..9cdafd5 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # nCognito Changelog +## 2.0.0 (2020-xx-xx) +#### New Feature +- added private bookmarks + +#### Improvement +- avoided opening next private window if incognito window already exists +- avoided opening always in incognito in non-private tab via link + ## 1.0.2 (2019-02-08) #### Repository Changes - updated dependencies diff --git a/README.md b/README.md index 12ccb52..7a28858 100755 --- a/README.md +++ b/README.md @@ -1,19 +1,78 @@ # nCognito + +## About + nCognito is a cross browsers (Chrome, Firefox, Edge, Opera) incognito mode plugin. -## Features +## Main Features + ### Panic mode + Quick escape window, tab or website by pressing at least 4 keys at the same time or using set shortcut. Hide content and mute tab before new page full load when evacuation method is set to `redirect`. ### Always in incognito + Set addresses, protocols and paths which should always be opened in private window. After detecting the address containing the set values, the page will be opened in the private window. ### Open in incognito + After click on the button in popup window, current address will be opened in private window. +## Setup + +##### 1. Clone repo + +```sh +git clone https://github.com/JB1905/ncognito.git +``` + +##### 2. Go to directory + +```sh +cd ncognito +``` + +##### 3. Install dependencies + +```sh +yarn + +# Or, use npm +npm i +``` + +##### 4. Run + +```sh +yarn watch + +# Or, use npm +npm run watch +``` + +### Chrome + +- open the Extension Management page by navigating to `chrome://extensions` +- enable Developer Mode by clicking the toggle switch next to Developer mode +- click the `LOAD UNPACKED` button and select the **dist** in the extension directory + +### Firefox + +- enter `about:debugging` in the URL bar +- click `This Firefox` +- click `Load Temporary Add-on` +- open the **dist** in the extension’s directory and select any file inside + +## Build with + +- [Vue](https://vuejs.org/) +- [TypeScript](https://www.typescriptlang.org/) +- [SCSS](https://sass-lang.com/) + ## License + This project is licensed under the MIT License © 2018-present Jakub Biesiada diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..64b84ff --- /dev/null +++ b/index.d.ts @@ -0,0 +1 @@ +declare module 'extensionizer'; diff --git a/package.json b/package.json index a931d16..b0ef7f2 100644 --- a/package.json +++ b/package.json @@ -1,46 +1,70 @@ { "name": "ncognito", - "version": "1.0.2", + "version": "2.0.0", "description": "Cross browser incognito mode extension", "author": "Jakub Biesiada", "license": "MIT", "scripts": { - "release": "npm run prettier && npm run lint && npm run build", + "release": "rimraf dist/* && npm run prettier && npm run lint && npm run build", "build": "webpack --env build", "build:dev": "webpack --env dev", "watch": "npm run build -- --watch", "watch:dev": "npm run build:dev -- --watch", - "lint": "eslint ./src --fix", - "prettier": "prettier --write './src/**/*.{vue,js,scss,html}'" + "lint": "eslint 'src/**/*.{vue,ts}' --fix", + "prettier": "prettier --write 'src/**/*.{vue,ts,scss,html}'", + "commit": "git-cz", + "prepare": "husky install", + "pre-commit": "lint-staged" }, "dependencies": { - "vue": "^2.6.10" + "vue": "^3.0.0" }, "devDependencies": { - "@vue/cli-plugin-babel": "^3.7.0", - "babel-eslint": "^10.0.1", - "babel-loader": "^8.0.6", - "copy-webpack-plugin": "^5.0.3", - "css-loader": "^2.1.1", - "eslint": "^5.16.0", - "eslint-plugin-prettier": "^3.1.0", - "eslint-plugin-vue": "^5.2.2", + "@typescript-eslint/parser": "^4.29.0", + "@vue/compiler-sfc": "^3.1.5", + "copy-webpack-plugin": "^8.1.1", + "css-loader": "^5.2.4", + "cz-conventional-changelog": "3.3.0", + "eslint": "7.32.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^3.4.0", + "eslint-plugin-vue": "^7.15.1", "extensionizer": "^1.0.1", - "node-sass": "^4.12.0", - "platform": "^1.3.5", - "prettier": "^1.17.1", - "sass-loader": "^7.1.0", - "style-loader": "^0.23.1", - "vue-eslint-parser": "^6.0.4", - "vue-loader": "^15.7.0", - "vue-template-compiler": "^2.6.10", - "webpack": "^4.31.0", + "husky": "^7.0.1", + "lint-staged": "^11.1.1", + "node-sass": "^6.0.1", + "platform": "^1.3.6", + "prettier": "^2.3.2", + "sass-loader": "^11.1.1", + "style-loader": "^2.0.0", + "ts-loader": "^9.1.2", + "typescript": "^4.2.4", + "vue-eslint-parser": "^7.10.0", + "vue-loader": "^16.0.0-beta.7", + "webpack": "^5.48.0", "webpack-chrome-extension-reloader": "^1.3.0", - "webpack-cli": "^3.3.2" + "webpack-cli": "^4.7.2" + }, + "lint-staged": { + "src/**/*.{vue,ts}": [ + "npm run prettier", + "npm run lint" + ], + "src/**/*.{scss}": [ + "npm run prettier" + ], + "src/**/*.{html}": [ + "npm run prettier" + ] }, "browserslist": [ "> 0.25%", "not ie 11", "not op_mini all" - ] + ], + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + } } diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json new file mode 100644 index 0000000..831233d --- /dev/null +++ b/src/_locales/en/messages.json @@ -0,0 +1,135 @@ +{ + "extensionDescription": { + "message": "Incognito mode extension", + "description": "Description of the extension." + }, + "settingsTitle": { + "message": "Settings" + }, + "inPrivateTitle": { + "message": "Open in private window" + }, + "x": { + "message": "Private Favorite" + }, + "xx": { + "message": "Enable" + }, + "w": { + "message": "Other" + }, + "ww": { + "message": "Open in non-private window" + }, + "f": { + "message": "Always incognito" + }, + "xx": { + "message": "Enable" + }, + "fff": { + "message": "Add addresses, protocols or paths to be opened only in private mode" + }, + "ffff": { + "message": "Address" + }, + "fffff": { + "message": "Protocol" + }, + "ffffff": { + "message": "Path" + }, + "a": { + "message": "e.g: google, http" + }, + "g": { + "message": "Add" + }, + "p": { + "message": "URL" + }, + "px": { + "message": "Type" + }, + "zzz": { + "message": "Remove" + }, + "ap": { + "message": "Clear" + }, + "s": { + "message": "Item already exists" + }, + "sp": { + "message": "Type and value are required" + }, + "spw": { + "message": "Are you sure you want to remove this addresses?" + }, + "spx": { + "message": "Are you sure you want to erase saved addresses?" + }, + "dsa": { + "message": "Action" + }, + "das": { + "message": "Close tab" + }, + "h": { + "message": "Hide tab" + }, + "cw": { + "message": "Close window" + }, + "hw": { + "message": "Hide window" + }, + "haw": { + "message": "Hide all windows" + }, + "mw": { + "message": "Minimize window" + }, + "rtw": { + "message": "Redirect to website" + }, + "pcw": { + "message": "e.g: https://www.mozilla.org" + }, + "ax": { + "message": "Add" + }, + "hc": { + "message": "Hide Content" + }, + "mm": { + "message": "Mute Media" + }, + "waoe": { + "message": "Way of evacuation" + }, + "pnm": { + "message": "Pianist's mode" + }, + "shrt": { + "message": "Shortcode" + }, + "plcsh": { + "message": "e.g: shift+e" + }, + "aaa": { + "message": "Set" + }, + "i": { + "message": "Leaving the private mode by simultaneously pressing at least 4 keys" + }, + "panm": { + "message": "Panic mode" + }, + "eee": { + "message": "Enable" + }, + "bookmarks": { + "message": "nCognito Bookmarks" + } +} diff --git a/src/_locales/pl/messages.json b/src/_locales/pl/messages.json new file mode 100644 index 0000000..1c5dad2 --- /dev/null +++ b/src/_locales/pl/messages.json @@ -0,0 +1,12 @@ +{ + "extensionDescription": { + "message": "Rozszerzenie trybu incognito", + "description": "Opis rozszerzenia." + }, + "settingsTitle": { + "message": "Ustawienia" + }, + "inPrivateTitle": { + "message": "Otwórz w oknie prywatnym" + } +} diff --git a/src/background.js b/src/background.js deleted file mode 100644 index 5d5c14e..0000000 --- a/src/background.js +++ /dev/null @@ -1,41 +0,0 @@ -import extension from 'extensionizer'; - -let firstWindow = true; -let firstTab = true; - -function handleMessage(req) { - const { url, action, mute } = req; - - if (url) { - if (firstWindow) { - firstWindow = false; - - extension.windows.create({ - incognito: true, - url - }); - } else if (!firstWindow && firstTab) { - firstTab = false; - - extension.tabs.create({ url }); - } - } - - if (action === 'tab') { - extension.tabs.query({ active: true }, tab => - extension.tabs.remove(tab[0].id) - ); - } else if (action === 'window') { - extension.windows.getCurrent(window => extension.windows.remove(window.id)); - } - - if (mute) { - extension.tabs.query({ active: true }, tab => - extension.tabs.update(tab[0].id, { muted: true }) - ); - } -} - -extension.runtime.onMessage.addListener(e => handleMessage(e)); -extension.windows.onCreated.addListener(() => (firstWindow = false)); -extension.windows.onRemoved.addListener(() => (firstWindow = true)); diff --git a/src/background/events.ts b/src/background/events.ts new file mode 100644 index 0000000..1e471ca --- /dev/null +++ b/src/background/events.ts @@ -0,0 +1,64 @@ +import extension from 'extensionizer'; + +import { ActionType } from '../shared/constants/ActionType'; + +let privateWindow: any = null; +// let newTab: any = true; +let privateTabs: any = []; + +extension.windows.onCreated.addListener((e: any) => { + if (e.incognito) { + privateWindow = e.id; + } +}); + +extension.windows.onRemoved.addListener((e: any) => { + if (e === privateWindow) { + privateWindow = null; + } +}); + +const runAction = (action: ActionType) => { + if (action === ActionType.CloseTab) { + extension.tabs.query({ active: true }, (tab: any) => + extension.tabs.remove(tab[0].id) + ); + } else if (action === ActionType.CloseWindow) { + extension.windows.getCurrent((window: any) => + extension.windows.remove(window.id) + ); + } +}; + +const runMuteActiveTab = () => { + extension.tabs.query({ active: true }, (tab: any) => + extension.tabs.update(tab[0].id, { muted: true }) + ); +}; + +const handleMessage = (req: any, _: any, sendResponse: any) => { + const { url, action, mute } = req; + + if (url) { + if (!privateWindow) { + return extension.windows.create({ incognito: true, url }, (res: any) => { + privateWindow = res.id; + }); + } else { + return extension.tabs.create( + { windowId: privateWindow, url }, + (res: any) => privateTabs.push(res.id) + ); + } + + // sendResponse(); + } + + runAction(action); + + if (mute) { + runMuteActiveTab(); + } +}; + +extension.runtime.onMessage.addListener(handleMessage); diff --git a/src/background/index.ts b/src/background/index.ts new file mode 100644 index 0000000..9b0fdf7 --- /dev/null +++ b/src/background/index.ts @@ -0,0 +1,3 @@ +import './openInNonPrivate'; +import './privateFavorite'; +import './events'; diff --git a/src/background/openInNonPrivate.ts b/src/background/openInNonPrivate.ts new file mode 100644 index 0000000..dc92369 --- /dev/null +++ b/src/background/openInNonPrivate.ts @@ -0,0 +1,91 @@ +import extension from 'extensionizer'; + +import { supportedProtocols } from '../shared/constants/supportedProtocols'; + +import { StoreKey } from '../shared/enums/StoreKey'; + +import { + openInNonPrivate, + alwaysCreateNewNonPrivate, + openExistingWindowNonPrivate, +} from '../../features.config.json'; + +if (openInNonPrivate) { + const CONTEXT_MENU_ID = 'open-in-non-private-window'; + + extension.contextMenus.create({ + title: 'Open in non-private window', + id: CONTEXT_MENU_ID, + visible: false, // TODO + }); + + extension.windows.onFocusChanged.addListener((activeWindow: any) => { + extension.tabs.query( + { active: true, windowId: activeWindow }, + ([currentTab]) => { + // let supported = false; + + // extension.tabs.onActivated.addListener(() => { + // supported = (supportedProtocols as any).includes( + // currentTab.url.split(':')[0] + // ); + + // console.log({ supported }); + // }); + + if (currentTab) { + extension.storage.local.get( + StoreKey.OpenInNonPrivateEnabled, + (res: any) => { + extension.windows.getCurrent(({ incognito }: any) => { + extension.contextMenus.update(CONTEXT_MENU_ID, { + visible: incognito && res.openInNonPrivateEnabled, + // && (supportedProtocols as any).includes( + // currentTab.url.split(':')[0] + // ), + }); + }); + } + ); + } + } + ); + }); + + extension.contextMenus.onClicked.addListener( + ({ menuItemId, linkUrl, pageUrl }: any) => { + if (menuItemId === CONTEXT_MENU_ID) { + const url = linkUrl ?? pageUrl; + + const focusWindow = (windowId: any) => { + extension.windows.update(windowId, { focused: true }); + }; + + extension.tabs.query({ currentWindow: false, url }, ([currentTab]) => { + if (currentTab && !alwaysCreateNewNonPrivate) { + focusWindow(currentTab.windowId); + } else { + if (openExistingWindowNonPrivate) { + extension.windows.getAll((windows) => { + const nonPrivateWindow = windows.find( + (window: any) => !window.incognito + ); + + if (nonPrivateWindow) { + extension.tabs.create({ + windowId: nonPrivateWindow.id, + url, + }); + + focusWindow(nonPrivateWindow.id); + } else { + extension.windows.create({ url }); + } + }); + } + } + }); + } + } + ); +} diff --git a/src/background/privateFavorite.ts b/src/background/privateFavorite.ts new file mode 100644 index 0000000..87dbf96 --- /dev/null +++ b/src/background/privateFavorite.ts @@ -0,0 +1,41 @@ +import extension from 'extensionizer'; + +import { StoreKey } from '../shared/enums/StoreKey'; + +import { privateFavorite } from '../../features.config.json'; + +if (privateFavorite) { + const createBookmark = () => { + extension.bookmarks.create( + // { title: 'nCognito Bookmarks' }, + ({ id }: any) => { + extension.storage.local.set({ + bookmarksFolder: { id }, + }); + } + ); + }; + + extension.storage.local.get( + StoreKey.BookmarkFolder, + ({ bookmarksFolder }: any) => { + if (bookmarksFolder === undefined) { + return createBookmark(); + } + + extension.bookmarks.get(bookmarksFolder.id, (bookmarks: any) => { + if (bookmarks) { + const exists = bookmarks.find( + (item: any) => item.id === bookmarksFolder.id + ); + + if (exists) { + createBookmark(); + } + } else { + createBookmark(); + } + }); + } + ); +} diff --git a/src/content/checkAlwaysIncognitoUrl.ts b/src/content/checkAlwaysIncognitoUrl.ts new file mode 100644 index 0000000..34c50d5 --- /dev/null +++ b/src/content/checkAlwaysIncognitoUrl.ts @@ -0,0 +1,32 @@ +import extension from 'extensionizer'; + +import { StoreKey } from '../shared/enums/StoreKey'; + +import { alwaysIncognito } from '../../features.config.json'; + +if (alwaysIncognito) { + // const + + const checkAlwaysIncognitoUrl = (e: any) => { + if (e.target.href) { + e.preventDefault(); + + // TODO refactor + extension.storage.local.get(StoreKey.Addresses, ({ addresses }: any) => { + addresses.map(({ url }: any) => { + if (e.target.href.includes(url)) { + extension.runtime.sendMessage({ + url: e.target.href, + }); + } else { + window.location = e.target.href; + } + }); + }); + } else { + window.location = e.target.href; + } + }; + + document.addEventListener('click', checkAlwaysIncognitoUrl); +} diff --git a/src/content/escape.ts b/src/content/escape.ts new file mode 100644 index 0000000..ce781ea --- /dev/null +++ b/src/content/escape.ts @@ -0,0 +1,68 @@ +import extension from 'extensionizer'; + +import { ActionType } from '../shared/constants/ActionType'; +import { EvacuationWay } from '../shared/enums/EvacuationWay'; +import { StoreKey } from '../shared/enums/StoreKey'; + +import { panicMode } from '../../features.config.json'; + +if (panicMode) { + const keys: any = []; + + const onKeyDown = (e: any) => { + extension.storage.local.get(StoreKey.Evacuation, (res: any) => { + if (res.evacuation) { + if (!keys.includes(e.key)) { + keys.push(e.key); + } + + if ( + res.evacuation.name === EvacuationWay.Pianist && + keys.length > 4 + // || + // res.evacuation.name === EvacuationWay.Shortcode + // && checkArrays(keys, res) + ) { + escapeFromIncognito(); + } + } + }); + }; + + const onKeyUp = (e: any) => keys.splice(e.key, 1); + + const escapeFromIncognito = () => { + extension.storage.local.get(StoreKey.Action, ({ action }: any) => { + if (action?.name === ActionType.Redirect) { + extension.storage.local.get(StoreKey.Options, (res: any) => { + if (res.options) { + if (res.options.hide) document.body.style.display = 'none'; + + if (res.options.mute) { + extension.runtime.sendMessage({ + mute: true, + }); + } + } + }); + + window.location.href = action.address; + } else if (action.name === ActionType.CloseTab) { + extension.runtime.sendMessage({ + action: ActionType.CloseTab, + }); + } else if (action.name === ActionType.CloseWindow) { + extension.runtime.sendMessage({ + action: ActionType.CloseWindow, + }); + } + }); + }; + + extension.storage.local.get(StoreKey.PanicModeEnabled, (res: any) => { + if (res.panicModeEnabled) { + window.addEventListener('keydown', onKeyDown); + window.addEventListener('keyup', onKeyUp); + } + }); +} diff --git a/src/content/index.ts b/src/content/index.ts new file mode 100755 index 0000000..fa11990 --- /dev/null +++ b/src/content/index.ts @@ -0,0 +1,3 @@ +import './checkAlwaysIncognitoUrl'; +import './openInIncognito'; +import './escape'; diff --git a/src/content/openInIncognito.ts b/src/content/openInIncognito.ts new file mode 100644 index 0000000..b7252c0 --- /dev/null +++ b/src/content/openInIncognito.ts @@ -0,0 +1,55 @@ +import extension from 'extensionizer'; + +import { IncognitoPattern } from '../shared/enums/IncognitoPattern'; +import { StoreKey } from '../shared/enums/StoreKey'; + +import { alwaysIncognito } from '../../features.config.json'; + +if (alwaysIncognito) { + // const addNew = (newW) => { + // extension.storage.local.get('openedWindows', (windows) => { + // const x = JSON.parse(windows); + + // x.push(newW); + + // extension.storage.local.set('openedWindows', JSON.stringify(x)); + // }); + // }; + + const inIncognito = () => { + extension.storage.local.get(StoreKey.Addresses, ({ addresses }: any) => { + alert(addresses); + JSON.parse(addresses).map(({ type, url }: any) => { + // alert(inPrivate.find((item) => item.type === type && item.url === url)); + + // if (inPrivate.find((item) => item.type === type && item.url === url)) { + // return; + // } + + if ( + (type === IncognitoPattern.Address && + window.location.hostname.includes(url)) || + (type === IncognitoPattern.Path && + window.location.pathname.includes(url)) || + (type === IncognitoPattern.Protocol && + window.location.protocol === `${url}:`) + ) { + extension.runtime.sendMessage( + { + url: window.location.href, + }, + () => { + // inPrivate.push({ type, url }); + } + ); + } + }); + }); + }; + + extension.storage.local.get(StoreKey.IncognitoEnabled, (res: any) => { + if (res.incognitoEnabled) { + inIncognito(); + } + }); +} diff --git a/src/helpers/checkArrays.js b/src/helpers/checkArrays.js deleted file mode 100644 index 40679ed..0000000 --- a/src/helpers/checkArrays.js +++ /dev/null @@ -1,13 +0,0 @@ -export const checkArrays = (keys, res) => { - const shortcode = res.evacuation.shortcode.toLowerCase().split('+'); - - let equal = false; - - if (keys.length === shortcode.length) { - keys.sort().map((key, index) => { - if (key.toLowerCase() === shortcode.sort()[index]) equal = true; - }); - } - - return equal; -}; diff --git a/src/helpers/pattern.js b/src/helpers/pattern.js deleted file mode 100644 index 1bc0848..0000000 --- a/src/helpers/pattern.js +++ /dev/null @@ -1,9 +0,0 @@ -export const pattern = new RegExp( - '^((https?:)?\\/\\/)?' + - '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + - '((\\d{1,3}\\.){3}\\d{1,3}))' + - '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + - '(\\?[;&a-z\\d%_.~+=-]*)?' + - '(\\#[-a-z\\d_]*)?$', - 'i' -); diff --git a/src/icons/icon128.png b/src/icons/icon128.png old mode 100755 new mode 100644 index b200ace..3422bf7 Binary files a/src/icons/icon128.png and b/src/icons/icon128.png differ diff --git a/src/icons/icon48.png b/src/icons/icon48.png old mode 100755 new mode 100644 index d1005da..b14c675 Binary files a/src/icons/icon48.png and b/src/icons/icon48.png differ diff --git a/src/index.js b/src/index.js deleted file mode 100755 index 1d148de..0000000 --- a/src/index.js +++ /dev/null @@ -1,83 +0,0 @@ -import extension from 'extensionizer'; - -import { checkArrays } from './helpers/checkArrays'; - -function inIncognito() { - extension.storage.local.get('addresses', res => { - if (res.addresses) { - res.addresses.map(address => { - if ( - (address.type === 'address' && - window.location.hostname.includes(address.url)) || - (address.type === 'path' && - window.location.pathname.includes(address.url)) || - (address.type === 'protocol' && - window.location.protocol === `${address.url}:`) - ) { - extension.runtime.sendMessage({ - url: window.location.href - }); - } - }); - } - }); -} - -extension.storage.local.get('incognitoEnabled', res => { - if (res.incognitoEnabled) inIncognito(); -}); - -const keys = []; - -const onKeyDown = e => { - extension.storage.local.get('evacuation', res => { - if (res.evacuation) { - if (!keys.includes(e.key)) keys.push(e.key); - - if ( - (res.evacuation.name === 'piano' && keys.length > 4) || - (res.evacuation.name === 'shortcode' && checkArrays(keys, res)) - ) - runEscape(); - } - }); -}; - -const onKeyUp = e => keys.splice(e.key, 1); - -function runEscape() { - extension.storage.local.get('action', res => { - if (res.action) { - if (res.action.name === 'redirect') { - extension.storage.local.get('options', res => { - if (res.options) { - if (res.options.hide) document.body.style.display = 'none'; - - if (res.options.mute) { - extension.runtime.sendMessage({ - mute: true - }); - } - } - }); - - window.location.href = res.action.address; - } else if (res.action.name === 'tab') { - extension.runtime.sendMessage({ - action: 'tab' - }); - } else if (res.action.name === 'window') { - extension.runtime.sendMessage({ - action: 'window' - }); - } - } - }); -} - -extension.storage.local.get('panicModeEnabled', res => { - if (res.panicModeEnabled) { - window.addEventListener('keydown', onKeyDown); - window.addEventListener('keyup', onKeyUp); - } -}); diff --git a/src/manifest.json b/src/manifest.json index c666aea..9add336 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,8 +1,8 @@ { "name": "nCognito", - "description": "Cross browser incognito mode extension", + "description": "__MSG_extensionDescription__", "manifest_version": 2, - "version": "1.0.2", + "version": "2.0.0", "author": "Jakub Biesiada", "homepage_url": "https://github.com/JB1905/ncognito", "icons": { @@ -12,13 +12,13 @@ "browser_action": { "default_icon": "./icons/icon48.png", "default_title": "nCognito", - "default_popup": "popup/popup.html" + "default_popup": "popup/index.html" }, "background": { "scripts": ["background.js"] }, "options_ui": { - "page": "options/options.html" + "page": "options/index.html" }, "content_scripts": [ { @@ -26,5 +26,6 @@ "js": ["index.js"] } ], - "permissions": ["tabs", "storage", "history"] + "permissions": ["tabs", "storage", "history", "bookmarks", "contextMenus"], + "default_locale": "en" } diff --git a/src/options/App.vue b/src/options/App.vue index a3256f3..f26c2fb 100644 --- a/src/options/App.vue +++ b/src/options/App.vue @@ -1,26 +1,47 @@ - - diff --git a/src/options/Panic/Action.vue b/src/options/Panic/Action.vue deleted file mode 100644 index db02d54..0000000 --- a/src/options/Panic/Action.vue +++ /dev/null @@ -1,172 +0,0 @@ - - - - - diff --git a/src/options/Panic/Evacuation.vue b/src/options/Panic/Evacuation.vue deleted file mode 100644 index 90e4ec7..0000000 --- a/src/options/Panic/Evacuation.vue +++ /dev/null @@ -1,117 +0,0 @@ - - - - - diff --git a/src/options/PanicMode.vue b/src/options/PanicMode.vue deleted file mode 100644 index 852cb6b..0000000 --- a/src/options/PanicMode.vue +++ /dev/null @@ -1,50 +0,0 @@ - - - - - diff --git a/src/options/components/AlwaysIncognito.vue b/src/options/components/AlwaysIncognito.vue new file mode 100644 index 0000000..b799b07 --- /dev/null +++ b/src/options/components/AlwaysIncognito.vue @@ -0,0 +1,213 @@ + + + + + diff --git a/src/options/components/Option.vue b/src/options/components/Option.vue new file mode 100644 index 0000000..f483bcd --- /dev/null +++ b/src/options/components/Option.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/src/options/components/Other.vue b/src/options/components/Other.vue new file mode 100644 index 0000000..caa0ac7 --- /dev/null +++ b/src/options/components/Other.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/src/options/components/PanicMode/Action.vue b/src/options/components/PanicMode/Action.vue new file mode 100644 index 0000000..168b7f1 --- /dev/null +++ b/src/options/components/PanicMode/Action.vue @@ -0,0 +1,236 @@ + + + + + diff --git a/src/options/components/PanicMode/Evacuation.vue b/src/options/components/PanicMode/Evacuation.vue new file mode 100644 index 0000000..2c463d8 --- /dev/null +++ b/src/options/components/PanicMode/Evacuation.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/src/options/components/PanicMode/index.vue b/src/options/components/PanicMode/index.vue new file mode 100644 index 0000000..604c3e4 --- /dev/null +++ b/src/options/components/PanicMode/index.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/options/components/PrivateFavorite.vue b/src/options/components/PrivateFavorite.vue new file mode 100644 index 0000000..f79934b --- /dev/null +++ b/src/options/components/PrivateFavorite.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/src/options/options.html b/src/options/index.html similarity index 79% rename from src/options/options.html rename to src/options/index.html index cf237d3..835b513 100644 --- a/src/options/options.html +++ b/src/options/index.html @@ -2,11 +2,15 @@ + + + Options - +
+ diff --git a/src/options/index.ts b/src/options/index.ts new file mode 100644 index 0000000..14d4651 --- /dev/null +++ b/src/options/index.ts @@ -0,0 +1,7 @@ +import { createApp } from 'vue'; + +import App from './App'; + +const app = createApp(App); + +app.mount('#app'); diff --git a/src/options/options.js b/src/options/options.js deleted file mode 100644 index dc04752..0000000 --- a/src/options/options.js +++ /dev/null @@ -1,7 +0,0 @@ -import Vue from 'vue'; -import App from './App'; - -new Vue({ - el: '#app', - render: h => h(App) -}); diff --git a/src/popup/App.vue b/src/popup/App.vue index ee745a6..a8f496a 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -6,50 +6,96 @@
- - + +
-