mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Fixed some deprecated functions, cleaned some code and added more Firefox compatibility.
This commit is contained in:
parent
d6f07cb600
commit
48e08f0bfb
6 changed files with 45 additions and 47 deletions
|
|
@ -12,7 +12,7 @@ var BLINK_TIMEOUT_REDIRECT_COUNT_DEFAULT = 1;
|
|||
|
||||
browserAction.show = function(callback, tab) {
|
||||
var data = {};
|
||||
if(!page.tabs[tab.id] || page.tabs[tab.id].stack.length == 0) {
|
||||
if (!page.tabs[tab.id] || page.tabs[tab.id].stack.length == 0) {
|
||||
browserAction.showDefault(callback, tab);
|
||||
return;
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ browserAction.show = function(callback, tab) {
|
|||
path: "/icons/19x19/" + browserAction.generateIconName(data.iconType, data.icon)
|
||||
});
|
||||
|
||||
if(data.popup) {
|
||||
if (data.popup) {
|
||||
browser.browserAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "popups/" + data.popup
|
||||
|
|
@ -34,13 +34,13 @@ browserAction.show = function(callback, tab) {
|
|||
}
|
||||
|
||||
browserAction.update = function(interval) {
|
||||
if(!page.tabs[page.currentTabId] || page.tabs[page.currentTabId].stack.length == 0) {
|
||||
if (!page.tabs[page.currentTabId] || page.tabs[page.currentTabId].stack.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = page.tabs[page.currentTabId].stack[page.tabs[page.currentTabId].stack.length - 1];
|
||||
|
||||
if(typeof data.visibleForMilliSeconds != "undefined") {
|
||||
if (typeof data.visibleForMilliSeconds != "undefined") {
|
||||
if(data.visibleForMilliSeconds <= 0) {
|
||||
browserAction.stackPop(page.currentTabId);
|
||||
browserAction.show(null, {"id": page.currentTabId});
|
||||
|
|
@ -50,7 +50,7 @@ browserAction.update = function(interval) {
|
|||
data.visibleForMilliSeconds -= interval;
|
||||
}
|
||||
|
||||
if(data.intervalIcon) {
|
||||
if (data.intervalIcon) {
|
||||
data.intervalIcon.counter += 1;
|
||||
if(data.intervalIcon.counter < data.intervalIcon.max) {
|
||||
return;
|
||||
|
|
@ -59,7 +59,7 @@ browserAction.update = function(interval) {
|
|||
data.intervalIcon.counter = 0;
|
||||
data.intervalIcon.index += 1;
|
||||
|
||||
if(data.intervalIcon.index > data.intervalIcon.icons.length - 1) {
|
||||
if (data.intervalIcon.index > data.intervalIcon.icons.length - 1) {
|
||||
data.intervalIcon.index = 0;
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ browserAction.showDefault = function(callback, tab) {
|
|||
stackData.iconType = "cross";
|
||||
}
|
||||
|
||||
if(page.tabs[tab.id].loginList.length > 0) {
|
||||
if (page.tabs[tab.id].loginList.length > 0) {
|
||||
stackData.iconType = "questionmark";
|
||||
stackData.popup = "popup_login.html";
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ browserAction.showDefault = function(callback, tab) {
|
|||
browserAction.stackAdd = function(callback, tab, icon, popup, level, push, visibleForMilliSeconds, visibleForPageUpdates, redirectOffset, dontShow) {
|
||||
var id = tab.id || page.currentTabId;
|
||||
|
||||
if(!level) {
|
||||
if (!level) {
|
||||
level = 1;
|
||||
}
|
||||
|
||||
|
|
@ -104,47 +104,47 @@ browserAction.stackAdd = function(callback, tab, icon, popup, level, push, visib
|
|||
"icon": icon
|
||||
}
|
||||
|
||||
if(popup) {
|
||||
if (popup) {
|
||||
stackData.popup = popup;
|
||||
}
|
||||
|
||||
if(visibleForMilliSeconds) {
|
||||
if (visibleForMilliSeconds) {
|
||||
stackData.visibleForMilliSeconds = visibleForMilliSeconds;
|
||||
}
|
||||
|
||||
if(visibleForPageUpdates) {
|
||||
if (visibleForPageUpdates) {
|
||||
stackData.visibleForPageUpdates = visibleForPageUpdates;
|
||||
}
|
||||
|
||||
if(redirectOffset) {
|
||||
if (redirectOffset) {
|
||||
stackData.redirectOffset = redirectOffset;
|
||||
}
|
||||
|
||||
if(push) {
|
||||
if (push) {
|
||||
browserAction.stackPush(stackData, id);
|
||||
}
|
||||
else {
|
||||
browserAction.stackUnshift(stackData, id);
|
||||
}
|
||||
|
||||
if(!dontShow) {
|
||||
if (!dontShow) {
|
||||
browserAction.show(null, {"id": id});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
browserAction.removeLevelFromStack = function(callback, tab, level, type, dontShow) {
|
||||
if(!page.tabs[tab.id]) {
|
||||
if (!page.tabs[tab.id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!type) {
|
||||
if (!type) {
|
||||
type = "<=";
|
||||
}
|
||||
|
||||
var newStack = [];
|
||||
for(var i = 0; i < page.tabs[tab.id].stack.length; i++) {
|
||||
if(
|
||||
for (var i = 0; i < page.tabs[tab.id].stack.length; i++) {
|
||||
if (
|
||||
(type == "<" && page.tabs[tab.id].stack[i].level >= level) ||
|
||||
(type == "<=" && page.tabs[tab.id].stack[i].level > level) ||
|
||||
(type == "=" && page.tabs[tab.id].stack[i].level != level) ||
|
||||
|
|
@ -159,7 +159,7 @@ browserAction.removeLevelFromStack = function(callback, tab, level, type, dontSh
|
|||
|
||||
page.tabs[tab.id].stack = newStack;
|
||||
|
||||
if(!dontShow) {
|
||||
if (!dontShow) {
|
||||
browserAction.show(callback, tab);
|
||||
}
|
||||
}
|
||||
|
|
@ -186,17 +186,17 @@ browserAction.stackUnshift = function(data, tabId) {
|
|||
|
||||
|
||||
browserAction.removeRememberPopup = function(callback, tab, removeImmediately) {
|
||||
if(!page.tabs[tab.id]) {
|
||||
if (!page.tabs[tab.id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(page.tabs[tab.id].stack.length == 0) {
|
||||
if( page.tabs[tab.id].stack.length == 0) {
|
||||
page.clearCredentials(tab.id);
|
||||
return;
|
||||
}
|
||||
var data = page.tabs[tab.id].stack[page.tabs[tab.id].stack.length - 1];
|
||||
|
||||
if(removeImmediately || !isNaN(data.visibleForPageUpdates)) {
|
||||
if (removeImmediately || !isNaN(data.visibleForPageUpdates)) {
|
||||
var currentMS = Date.now();
|
||||
if( removeImmediately || (data.visibleForPageUpdates <= 0 && data.redirectOffset > 0)) {
|
||||
browserAction.stackPop(tab.id);
|
||||
|
|
@ -261,7 +261,7 @@ function getValueOrDefault(settings, key, defaultVal, min) {
|
|||
}
|
||||
|
||||
browserAction.generateIconName = function(iconType, icon) {
|
||||
if(icon) {
|
||||
if (icon) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,22 +15,22 @@ page.blockedTabs = {};
|
|||
|
||||
page.initSettings = function() {
|
||||
event.onLoadSettings();
|
||||
if(!("checkUpdateKeePassXC" in page.settings)) {
|
||||
if (!("checkUpdateKeePassXC" in page.settings)) {
|
||||
page.settings.checkUpdateKeePassXC = 3;
|
||||
}
|
||||
if(!("autoCompleteUsernames" in page.settings)) {
|
||||
if (!("autoCompleteUsernames" in page.settings)) {
|
||||
page.settings.autoCompleteUsernames = 1;
|
||||
}
|
||||
if(!("autoFillAndSend" in page.settings)) {
|
||||
if (!("autoFillAndSend" in page.settings)) {
|
||||
page.settings.autoFillAndSend = 1;
|
||||
}
|
||||
if(!("usePasswordGenerator" in page.settings)) {
|
||||
if (!("usePasswordGenerator" in page.settings)) {
|
||||
page.settings.usePasswordGenerator = 1;
|
||||
}
|
||||
if(!("autoFillSingleEntry" in page.settings)) {
|
||||
if (!("autoFillSingleEntry" in page.settings)) {
|
||||
page.settings.autoFillSingleEntry = 0;
|
||||
}
|
||||
if(!("autoRetrieveCredentials" in page.settings)) {
|
||||
if (!("autoRetrieveCredentials" in page.settings)) {
|
||||
page.settings.autoRetrieveCredentials = 1;
|
||||
}
|
||||
localStorage.settings = JSON.stringify(page.settings);
|
||||
|
|
@ -38,7 +38,7 @@ page.initSettings = function() {
|
|||
|
||||
page.initOpenedTabs = function() {
|
||||
browser.tabs.query({}, function(tabs) {
|
||||
for(var i = 0; i < tabs.length; i++) {
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
page.createTabEntry(tabs[i].id);
|
||||
}
|
||||
});
|
||||
|
|
@ -57,14 +57,14 @@ page.switchTab = function(callback, tab) {
|
|||
}
|
||||
|
||||
page.clearCredentials = function(tabId, complete) {
|
||||
if(!page.tabs[tabId]) {
|
||||
if (!page.tabs[tabId]) {
|
||||
return;
|
||||
}
|
||||
|
||||
page.tabs[tabId].credentials = {};
|
||||
delete page.tabs[tabId].credentials;
|
||||
|
||||
if(complete) {
|
||||
if (complete) {
|
||||
page.tabs[tabId].loginList = [];
|
||||
|
||||
browser.tabs.sendMessage(tabId, {
|
||||
|
|
@ -84,17 +84,17 @@ page.createTabEntry = function(tabId) {
|
|||
|
||||
page.removePageInformationFromNotExistingTabs = function() {
|
||||
var rand = Math.floor(Math.random()*1001);
|
||||
if(rand == 28) {
|
||||
if (rand == 28) {
|
||||
browser.tabs.query({}, function(tabs) {
|
||||
var $tabIds = {};
|
||||
var $infoIds = Object.keys(page.tabs);
|
||||
|
||||
for(var i = 0; i < tabs.length; i++) {
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
$tabIds[tabs[i].id] = true;
|
||||
}
|
||||
|
||||
for(var i = 0; i < $infoIds.length; i++) {
|
||||
if(!($infoIds[i] in $tabIds)) {
|
||||
for (var i = 0; i < $infoIds.length; i++) {
|
||||
if (!($infoIds[i] in $tabIds)) {
|
||||
delete page.tabs[$infoIds[i]];
|
||||
}
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ page.removePageInformationFromNotExistingTabs = function() {
|
|||
};
|
||||
|
||||
page.debugConsole = function() {
|
||||
if(arguments.length > 1) {
|
||||
if (arguments.length > 1) {
|
||||
console.log(page.sprintf(arguments[0], arguments));
|
||||
}
|
||||
else {
|
||||
|
|
@ -125,7 +125,7 @@ page.debugDummy = function() {};
|
|||
page.debug = page.debugDummy;
|
||||
|
||||
page.setDebug = function(bool) {
|
||||
if(bool) {
|
||||
if (bool) {
|
||||
page.debug = page.debugConsole;
|
||||
return "Debug mode enabled";
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "chromeKeePassXC",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"description": "KeePassXC integration for modern web browsers",
|
||||
"author": "Sami Vänttinen",
|
||||
"icons": {
|
||||
|
|
@ -60,7 +60,6 @@
|
|||
}
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
"jquery-3.2.1.min.map",
|
||||
"icons/key_16x16.png",
|
||||
"icons/key_24x24.png"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
<p>
|
||||
<div class="checkbox">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="usePasswordGenerator" value="1" /> Activate password generator.
|
||||
<input type="checkbox" name="usePasswordGenerator" value="true" /> Activate password generator.
|
||||
</label>
|
||||
<span class="help-block">For all password-fields there will be an icon added to generate a new password.<br />
|
||||
It is generated by KeePassXC with the profile for automatically generated passwords for new entries.</span>
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
<p>
|
||||
<div class="checkbox">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="autoRetrieveCredentials" value="1" /> Automatically retrieve credentials.
|
||||
<input type="checkbox" name="autoRetrieveCredentials" value="true" /> Automatically retrieve credentials.
|
||||
</label>
|
||||
<span class="help-block">chromeKeePassXC will immediately retrieve the credentials when the tab is activated.</span>
|
||||
</div>
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<p>
|
||||
<div class="checkbox">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="autoFillSingleEntry" value="0" /> Automatically fill-in single credentials entry.
|
||||
<input type="checkbox" name="autoFillSingleEntry" value="false" /> Automatically fill-in single credentials entry.
|
||||
</label>
|
||||
<span class="help-block">If chromeKeePassXC does only receive a single entry from KeePassXC it automatically fills this credentials into the found credential fields.</span>
|
||||
<span class="bg-danger">Warning! Using auto-fill is not safe. Use at your own risk.</span>
|
||||
|
|
@ -114,7 +114,7 @@
|
|||
<p>
|
||||
<div class="checkbox">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="autoCompleteUsernames" value="1" /> Activate autocomplete for username fields.
|
||||
<input type="checkbox" name="autoCompleteUsernames" value="true" /> Activate autocomplete for username fields.
|
||||
</label>
|
||||
<span class="help-block">For all username fields on a page a dropdown list appears which contains all available credentials.</span>
|
||||
</div>
|
||||
|
|
@ -269,7 +269,7 @@
|
|||
<a target="_blank" href="https://github.com/varjolintu/">Sami Vänttinen</a>
|
||||
</p>
|
||||
<p>
|
||||
<a target="_blank" href="https://chrome.google.com/webstore/detail/chromeipass/ompiailgknfdndiefoaoiligalphfdae">Visit extension's page in Chrome Web store</a>
|
||||
<a target="_blank" href="https://chrome.google.com/webstore/detail/chromekeepassxc/iopaggbpplllidnfmcghoonnokmjoicf">Visit extension's page in Chrome Web store</a>
|
||||
</p>
|
||||
<p>
|
||||
<a target="_blank" href="https://github.com/varjolintu/chromeKeePassXC">Visit project's page in GitHub</a>.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ window.browser = (function () {
|
|||
|
||||
$(function() {
|
||||
browser.runtime.getBackgroundPage(function(global) {
|
||||
browser.tabs.getSelected(null, function(tab) {
|
||||
browser.tabs.query(null, function(tab) {
|
||||
//var data = global.tab_httpauth_list["tab" + tab.id];
|
||||
var data = global.page.tabs[tab.id].loginList;
|
||||
var ul = document.getElementById("login-list");
|
||||
|
|
|
|||
Loading…
Reference in a new issue