diff options
author | varjolintu <sami.vanttinen@gmail.com> | 2017-12-17 12:07:00 +0300 |
---|---|---|
committer | varjolintu <sami.vanttinen@gmail.com> | 2017-12-17 12:07:00 +0300 |
commit | c9bdd79a8eaf66c17533267d77dd87e5c6b8ab43 (patch) | |
tree | 185946f3a09c15f601edf6199f5b9772085f26d4 | |
parent | f200fe8000af824042672fa894d931035553227a (diff) |
Content script code cleaning. Removal of obsolete files
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | com.varjolintu.keepassxc-browser-chrome-win.json | 11 | ||||
-rw-r--r-- | com.varjolintu.keepassxc-browser-chrome.json | 11 | ||||
-rw-r--r-- | com.varjolintu.keepassxc-browser-firefox-win.json | 9 | ||||
-rw-r--r-- | com.varjolintu.keepassxc-browser-firefox.json | 9 | ||||
-rw-r--r-- | install.bat | 34 | ||||
-rwxr-xr-x | install.sh | 141 | ||||
-rw-r--r-- | keepassxc-browser/keepassxc-browser.js | 76 |
8 files changed, 19 insertions, 273 deletions
@@ -2,6 +2,7 @@ ========================= - Added support for OTP codes via context menu - Fixed HTTP auth +- General content script code cleaning 0.4.3 (9-12-2017) ========================= diff --git a/com.varjolintu.keepassxc-browser-chrome-win.json b/com.varjolintu.keepassxc-browser-chrome-win.json deleted file mode 100644 index acf8450..0000000 --- a/com.varjolintu.keepassxc-browser-chrome-win.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "com.varjolintu.keepassxc_browser", - "description": "KeepassXC integration with Chrome with Native Messaging support", - "path" : "keepassxc-proxy.bat", - "type": "stdio", - "allowed_origins": [ - "chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/", - "chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/", - "chrome-extension://jaikbblhommnkeialomogohhdlndpfbi/" - ] -}
\ No newline at end of file diff --git a/com.varjolintu.keepassxc-browser-chrome.json b/com.varjolintu.keepassxc-browser-chrome.json deleted file mode 100644 index 0fb2adb..0000000 --- a/com.varjolintu.keepassxc-browser-chrome.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "com.varjolintu.keepassxc_browser", - "description": "KeepassXC integration with Chrome with Native Messaging support", - "path" : "%%replace%%", - "type": "stdio", - "allowed_origins": [ - "chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/", - "chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/", - "chrome-extension://jaikbblhommnkeialomogohhdlndpfbi/" - ] -}
\ No newline at end of file diff --git a/com.varjolintu.keepassxc-browser-firefox-win.json b/com.varjolintu.keepassxc-browser-firefox-win.json deleted file mode 100644 index 6c4b9c4..0000000 --- a/com.varjolintu.keepassxc-browser-firefox-win.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "com.varjolintu.keepassxc_browser", - "description": "KeepassXC integration with Firefox with Native Messaging support", - "path" : "keepassxc-proxy.bat", - "type": "stdio", - "allowed_extensions": [ - "keepassxc-browser@sami.vanttinen" - ] -}
\ No newline at end of file diff --git a/com.varjolintu.keepassxc-browser-firefox.json b/com.varjolintu.keepassxc-browser-firefox.json deleted file mode 100644 index b98e59d..0000000 --- a/com.varjolintu.keepassxc-browser-firefox.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "com.varjolintu.keepassxc_browser", - "description": "KeepassXC integration with Firefox with Native Messaging support", - "path" : "%%replace%%", - "type": "stdio", - "allowed_extensions": [ - "keepassxc-browser@sami.vanttinen" - ] -}
\ No newline at end of file diff --git a/install.bat b/install.bat deleted file mode 100644 index 954957b..0000000 --- a/install.bat +++ /dev/null @@ -1,34 +0,0 @@ -:: Copyright 2014 The Chromium Authors. All rights reserved.
-:: Copyright 2017 Sami Vänttinen <sami.vanttinen@protonmail.com>
-:: Use of this source code is governed by a BSD-style license that can be
-:: found in the LICENSE file.
-:: Change HKCU to HKLM if you want to install globally.
-:: %~dp0 is the directory containing this bat script and ends with a backslash.
-@echo off
-echo.
-echo Select your browser:
-echo ====================
-echo 1) Chrome
-echo 2) Chromium
-echo 3) Firefox
-echo 4) Vivaldi
-set choice=
-set /p choice=1-4:
-if '%choice%'=='1' goto chrome
-if '%choice%'=='2' goto chromium
-if '%choice%'=='3' goto firefox
-if '%choice%'=='3' goto vivaldi
-goto end
-:chrome
-REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.varjolintu.keepassxc_browser" /ve /t REG_SZ /d "%~dp0com.varjolintu.keepassxc-browser-chrome.win.json" /f
-goto end
-:chromium
-REG ADD "HKCU\Software\Chromium\NativeMessagingHosts\com.varjolintu.keepassxc_browser" /ve /t REG_SZ /d "%~dp0com.varjolintu.keepassxc-browser-chrome.win.json" /f
-goto end
-:firefox
-REG ADD "HKCU\Software\Mozilla\NativeMessagingHosts\com.varjolintu.keepassxc_browser" /ve /t REG_SZ /d "%~dp0com.varjolintu.keepassxc-browser-firefox.win.json" /f
-goto end
-:vivaldi
-REG ADD "HKCU\Software\Vivaldi\NativeMessagingHosts\com.varjolintu.keepassxc_browser" /ve /t REG_SZ /d "%~dp0com.varjolintu.keepassxc-browser-chrome.win.json" /f
-goto end
-:end
\ No newline at end of file diff --git a/install.sh b/install.sh deleted file mode 100755 index c0bf959..0000000 --- a/install.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env bash - -# The MIT License (MIT) -# Copyright (c) 2016 Danny van Kooten -# Modifications (c) 2017 Sami Vänttinen - -# Permission is hereby granted, free of charge, to any person obtaining a copy of this software -# and associated documentation files (the "Software"), to deal in the Software without restriction, -# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -set -e - -DIR="$( cd "$( dirname "$0" )" && pwd )" -APP_NAME="com.varjolintu.keepassxc_browser" -HOST_FILE="$DIR" -KEEPASSXC_PATH="" - -# Find target dirs for various browsers & OS'es -# https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location -# https://wiki.mozilla.org/WebExtensions/Native_Messaging -if [ $(uname -s) == 'Darwin' ]; then - if [ "$(whoami)" == "root" ]; then - TARGET_DIR_CHROME="/Library/Google/Chrome/NativeMessagingHosts" - TARGET_DIR_CHROMIUM="/Library/Application Support/Chromium/NativeMessagingHosts" - TARGET_DIR_FIREFOX="/Library/Application Support/Mozilla/NativeMessagingHosts" - TARGET_DIR_VIVALDI="/Library/Application Support/Vivaldi/NativeMessagingHosts" - else - TARGET_DIR_CHROME="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" - TARGET_DIR_CHROMIUM="$HOME/Library/Application Support/Chromium/NativeMessagingHosts" - TARGET_DIR_FIREFOX="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts" - TARGET_DIR_VIVALDI="$HOME/Library/Application Support/Vivaldi/NativeMessagingHosts" - fi -else - if [ "$(whoami)" == "root" ]; then - TARGET_DIR_CHROME="/etc/opt/chrome/native-messaging-hosts" - TARGET_DIR_CHROMIUM="/etc/chromium/native-messaging-hosts" - TARGET_DIR_FIREFOX="/usr/lib/mozilla/native-messaging-hosts" - TARGET_DIR_VIVALDI="/etc/chromium/native-messaging-hosts" - else - TARGET_DIR_CHROME="$HOME/.config/google-chrome/NativeMessagingHosts" - TARGET_DIR_CHROMIUM="$HOME/.config/chromium/NativeMessagingHosts" - TARGET_DIR_FIREFOX="$HOME/.mozilla/native-messaging-hosts" - TARGET_DIR_VIVALDI="$HOME/.config/vivaldi/NativeMessagingHosts" - fi -fi - -if [ -e "$DIR/keepassxc-browser" ]; then - echo "Detected development binary" - HOST_FILE="$DIR/keepassxc-browser" -fi - -echo "" -echo "Select your browser:" -echo "====================" -echo "1) Chrome" -echo "2) Chromium" -echo "3) Firefox" -echo "4) Vivaldi" -echo -n "1-4: " -read BROWSER -echo "" - -# Set target dir from user input -if [[ "$BROWSER" == "1" ]]; then - BROWSER_NAME="Chrome" - TARGET_DIR="$TARGET_DIR_CHROME" -fi - -if [[ "$BROWSER" == "2" ]]; then - BROWSER_NAME="Chromium" - TARGET_DIR="$TARGET_DIR_CHROMIUM" -fi - -if [[ "$BROWSER" == "3" ]]; then - BROWSER_NAME="Firefox" - TARGET_DIR="$TARGET_DIR_FIREFOX" -fi - -if [[ "$BROWSER" == "4" ]]; then - BROWSER_NAME="Vivaldi" - TARGET_DIR="$TARGET_DIR_VIVALDI" -fi - -# Try to find the KeePassXC binary. -if [ $(uname -s) == 'Darwin' ]; then - KEEPASSXC_PATH="/Applications/KeePassXC.app" -else - KEEPASSXC_PATH="$(command -v keepassxc)" - if [ -z "$KEEPASSXC_PATH" ] ; then - echo "" - echo -n "KeePassXC binary not found. Give the location of KeePassXC binary: " - read KEEPASSXC_PATH - echo "" - fi -fi -echo "KeePassXC binary location set to $KEEPASSXC_PATH" -echo "Installing $BROWSER_NAME host config with path $KEEPASSXC_PATH" -echo "Press (ENTER) or give a new path to binary if it's not correct: " -read NEW_PATH - -if [ "$NEW_PATH" ]; then - KEEPASSXC_PATH="$NEW_PATH" - echo "New path set to: $KEEPASSXC_PATH" -fi - -# Add /Contents/MacOS/KeePassXC to darwin for exact binary path -if [ $(uname -s) == 'Darwin' ]; then - KEEPASSXC_PATH="$KEEPASSXC_PATH/Contents/MacOS/KeePassXC" -fi - -ESCAPED_PATH=${KEEPASSXC_PATH////\\/} - -# Create config dir if not existing -mkdir -p "$TARGET_DIR" - -# Copy manifest host config file -if [ "$BROWSER" == "1" ] || [ "$BROWSER" == "2" ] || [ "$BROWSER" == "4" ]; then - cp "$DIR/com.varjolintu.keepassxc-browser-chrome.json" "$TARGET_DIR/$APP_NAME.json" -else - cp "$DIR/com.varjolintu.keepassxc-browser-firefox.json" "$TARGET_DIR//$APP_NAME.json" -fi - -# Replace path to host -if [ $(uname -s) == 'Darwin' ]; then - sed -i "" -e "s/%%replace%%/$ESCAPED_PATH/g" "$TARGET_DIR/$APP_NAME.json" -else - sed -i -e "s/%%replace%%/$ESCAPED_PATH/g" "$TARGET_DIR/$APP_NAME.json" -fi - -# Set permissions for the manifest so that all users can read it. -chmod o+r "$TARGET_DIR/$APP_NAME.json" - -echo "Native messaging host for $BROWSER_NAME has been installed to $TARGET_DIR."
\ No newline at end of file diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js index 2d00087..b1a0101 100644 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -22,7 +22,7 @@ browser.runtime.onMessage.addListener(function(req, sender, callback) { combination = cipFields.getCombination('password', cip.p);
}
- let list = {};
+ let list = [];
if (cip.fillInStringFields(combination.fields, cip.credentials[req.id].stringFields, list)) {
cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]});
}
@@ -36,7 +36,7 @@ browser.runtime.onMessage.addListener(function(req, sender, callback) { }
else if (req.action === 'fill_pass_only') {
cip.receiveCredentialsIfNecessary();
- cip.fillInFromActiveElementPassOnly(false);
+ cip.fillInFromActiveElement(false, true);
}
else if (req.action === 'fill_totp') {
cip.receiveCredentialsIfNecessary();
@@ -534,7 +534,7 @@ var cipDefine = {}; cipDefine.selection = {
username: null,
password: null,
- fields: {}
+ fields: []
};
cipDefine.eventFieldClick = null;
@@ -671,7 +671,7 @@ cipDefine.resetSelection = function() { cipDefine.selection = {
username: null,
password: null,
- fields: {}
+ fields: []
};
};
@@ -714,10 +714,8 @@ cipDefine.markAllStringFields = function($chooser) { };
cipDefine.markFields = function ($chooser, $pattern) {
- //var $found = false;
jQuery($pattern).each(function() {
if (cipDefine.isFieldSelected(jQuery(this).data('cip-id'))) {
- //continue
return true;
}
@@ -731,16 +729,8 @@ cipDefine.markFields = function ($chooser, $pattern) { .click(cipDefine.eventFieldClick)
.hover(function() {jQuery(this).addClass('b2c-fixed-hover-field');}, function() {jQuery(this).removeClass('b2c-fixed-hover-field');});
$chooser.append($field);
- //$found = true;
}
});
-
- /* skip step if no entry was found
- if(!$found) {
- alert('No username field found.\nContinue with choosing a password field.'');
- jQuery('button#b2c-btn-skip').click();
- }
- */
};
cipDefine.prepareStep1 = function() {
@@ -763,14 +753,6 @@ cipDefine.prepareStep2 = function() { };
cipDefine.prepareStep3 = function() {
- /* skip step if no entry was found
- if(!jQuery('div#b2c-cipDefine-fields').data('username') && !jQuery('div#b2c-cipDefine-fields').data('password')) {
- alert('Neither an username field nor a password field were selected.\nNothing will be changed and chooser will be closed now.'');
- jQuery('button#b2c-btn-dismiss').click();
- return;
- }
- */
-
if (!cipDefine.selection.username && !cipDefine.selection.password) {
jQuery('button#b2c-btn-confirm:first').removeClass('b2c-btn-primary').attr('disabled', true);
}
@@ -1272,7 +1254,7 @@ cip.prepareFieldsForCredentials = function(autoFillInForSingle) { }
if (combination) {
- let list = {};
+ let list = [];
if (cip.fillInStringFields(combination.fields, cip.credentials[0].stringFields, list)) {
cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]});
}
@@ -1393,7 +1375,7 @@ cip.fillInCredentials = function(combination, onlyPassword, suppressWarnings) { }
};
-cip.fillInFromActiveElement = function(suppressWarnings) {
+cip.fillInFromActiveElement = function(suppressWarnings, passOnly = false) {
const el = document.activeElement;
if (el.tagName.toLowerCase() !== 'input') {
if (cipFields.combinations.length > 0) {
@@ -1411,42 +1393,21 @@ cip.fillInFromActiveElement = function(suppressWarnings) { else {
combination = cipFields.getCombination('username', fieldId);
}
- delete combination.loginId;
-
- cip.fillInCredentials(combination, false, suppressWarnings);
-};
-cip.fillInFromActiveElementPassOnly = function(suppressWarnings) {
- const el = document.activeElement;
- if (el.tagName.toLowerCase() !== 'input') {
- if (cipFields.combinations.length > 0) {
- cip.fillInCredentials(cipFields.combinations[0], false, suppressWarnings);
+ if (passOnly) {
+ if (!_f(combination.password)) {
+ const message = 'Unable to find a password field';
+ browser.runtime.sendMessage({
+ action: 'alert',
+ args: [message]
+ });
+ return;
}
- return;
- }
-
- cipFields.setUniqueId(jQuery(el));
- const fieldId = cipFields.prepareId(jQuery(el).attr('data-cip-id'));
- let combination = null;
- if (el.type && el.type.toLowerCase() === 'password') {
- combination = cipFields.getCombination('password', fieldId);
- }
- else {
- combination = cipFields.getCombination('username', fieldId);
- }
-
- if (!_f(combination.password)) {
- const message = 'Unable to find a password field';
- browser.runtime.sendMessage({
- action: 'alert',
- args: [message]
- });
- return;
}
delete combination.loginId;
- cip.fillInCredentials(combination, true, suppressWarnings);
+ cip.fillInCredentials(combination, false, suppressWarnings);
};
cip.fillInFromActiveElementTOTPOnly = function(suppressWarnings) {
@@ -1493,7 +1454,6 @@ cip.fillInStringFields = function(fields, StringFields, filledInFields) { for (let i = 0; i < fields.length; i++) {
const $sf = _fs(fields[i]);
if ($sf && StringFields[i]) {
- //$sf.val(StringFields[i].Value);
cip.setValue($sf, StringFields[i].Value);
filledInFields.list.push(fields[i]);
$filledIn = true;
@@ -1549,7 +1509,7 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) { filledIn = true;
}
- let list = {};
+ let list = [];
if (cip.fillInStringFields(combination.fields, cip.credentials[0].stringFields, list)) {
cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]});
filledIn = true;
@@ -1579,7 +1539,7 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) { filledIn = true;
}
- let list = {};
+ let list = [];
if (cip.fillInStringFields(combination.fields, cip.credentials[combination.loginId].stringFields, list)) {
cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]});
filledIn = true;
@@ -1632,7 +1592,7 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) { pField.data('unchanged', true);
}
- let list = {};
+ let list = [];
if (cip.fillInStringFields(combination.fields, valStringFields, list)) {
cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]});
}
|