mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
Apply Prettier (#2238)
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
@-webkit-keyframes bitwardenfill {
|
||||
0% {
|
||||
-webkit-transform: scale(1.0, 1.0);
|
||||
}
|
||||
0% {
|
||||
-webkit-transform: scale(1, 1);
|
||||
}
|
||||
|
||||
50% {
|
||||
-webkit-transform: scale(1.2, 1.2);
|
||||
}
|
||||
50% {
|
||||
-webkit-transform: scale(1.2, 1.2);
|
||||
}
|
||||
|
||||
100% {
|
||||
-webkit-transform: scale(1.0, 1.0);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: scale(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-keyframes bitwardenfill {
|
||||
0% {
|
||||
transform: scale(1.0, 1.0);
|
||||
}
|
||||
0% {
|
||||
transform: scale(1, 1);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1.2, 1.2);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.2, 1.2);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: scale(1.0, 1.0);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
span[data-bwautofill].com-bitwarden-browser-animated-fill {
|
||||
display: inline-block;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.com-bitwarden-browser-animated-fill {
|
||||
animation: bitwardenfill 200ms ease-in-out 0ms 1;
|
||||
-webkit-animation: bitwardenfill 200ms ease-in-out 0ms 1;
|
||||
animation: bitwardenfill 200ms ease-in-out 0ms 1;
|
||||
-webkit-animation: bitwardenfill 200ms ease-in-out 0ms 1;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,43 +1,43 @@
|
||||
document.addEventListener('DOMContentLoaded', event => {
|
||||
let pageHref: string = null;
|
||||
let filledThisHref = false;
|
||||
let delayFillTimeout: number;
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
let pageHref: string = null;
|
||||
let filledThisHref = false;
|
||||
let delayFillTimeout: number;
|
||||
|
||||
const enabledKey = 'enableAutoFillOnPageLoad';
|
||||
chrome.storage.local.get(enabledKey, (obj: any) => {
|
||||
if (obj != null && obj[enabledKey] === true) {
|
||||
setInterval(() => doFillIfNeeded(), 500);
|
||||
}
|
||||
});
|
||||
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: Function) => {
|
||||
if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||
filledThisHref = true;
|
||||
}
|
||||
});
|
||||
|
||||
function doFillIfNeeded(force: boolean = false) {
|
||||
if (force || pageHref !== window.location.href) {
|
||||
if (!force) {
|
||||
// Some websites are slow and rendering all page content. Try to fill again later
|
||||
// if we haven't already.
|
||||
filledThisHref = false;
|
||||
if (delayFillTimeout != null) {
|
||||
window.clearTimeout(delayFillTimeout);
|
||||
}
|
||||
delayFillTimeout = window.setTimeout(() => {
|
||||
if (!filledThisHref) {
|
||||
doFillIfNeeded(true);
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
pageHref = window.location.href;
|
||||
const msg: any = {
|
||||
command: 'bgCollectPageDetails',
|
||||
sender: 'autofiller',
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
const enabledKey = "enableAutoFillOnPageLoad";
|
||||
chrome.storage.local.get(enabledKey, (obj: any) => {
|
||||
if (obj != null && obj[enabledKey] === true) {
|
||||
setInterval(() => doFillIfNeeded(), 500);
|
||||
}
|
||||
});
|
||||
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: Function) => {
|
||||
if (msg.command === "fillForm" && pageHref === msg.url) {
|
||||
filledThisHref = true;
|
||||
}
|
||||
});
|
||||
|
||||
function doFillIfNeeded(force: boolean = false) {
|
||||
if (force || pageHref !== window.location.href) {
|
||||
if (!force) {
|
||||
// Some websites are slow and rendering all page content. Try to fill again later
|
||||
// if we haven't already.
|
||||
filledThisHref = false;
|
||||
if (delayFillTimeout != null) {
|
||||
window.clearTimeout(delayFillTimeout);
|
||||
}
|
||||
delayFillTimeout = window.setTimeout(() => {
|
||||
if (!filledThisHref) {
|
||||
doFillIfNeeded(true);
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
pageHref = window.location.href;
|
||||
const msg: any = {
|
||||
command: "bgCollectPageDetails",
|
||||
sender: "autofiller",
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
const inputTags = ['input', 'textarea', 'select'];
|
||||
const labelTags = ['label', 'span'];
|
||||
const attributes = ['id', 'name', 'label-aria', 'placeholder'];
|
||||
const invalidElement = chrome.i18n.getMessage('copyCustomFieldNameInvalidElement');
|
||||
const noUniqueIdentifier = chrome.i18n.getMessage('copyCustomFieldNameNotUnique');
|
||||
const inputTags = ["input", "textarea", "select"];
|
||||
const labelTags = ["label", "span"];
|
||||
const attributes = ["id", "name", "label-aria", "placeholder"];
|
||||
const invalidElement = chrome.i18n.getMessage("copyCustomFieldNameInvalidElement");
|
||||
const noUniqueIdentifier = chrome.i18n.getMessage("copyCustomFieldNameNotUnique");
|
||||
|
||||
let clickedEl: HTMLElement = null;
|
||||
|
||||
// Find the best attribute to be used as the Name for an element in a custom field.
|
||||
function getClickedElementIdentifier() {
|
||||
if (clickedEl == null) {
|
||||
return invalidElement;
|
||||
}
|
||||
if (clickedEl == null) {
|
||||
return invalidElement;
|
||||
}
|
||||
|
||||
const clickedTag = clickedEl.nodeName.toLowerCase();
|
||||
let inputEl = null;
|
||||
const clickedTag = clickedEl.nodeName.toLowerCase();
|
||||
let inputEl = null;
|
||||
|
||||
// Try to identify the input element (which may not be the clicked element)
|
||||
if (labelTags.includes(clickedTag)) {
|
||||
let inputId = null;
|
||||
if (clickedTag === 'label') {
|
||||
inputId = clickedEl.getAttribute('for');
|
||||
} else {
|
||||
inputId = clickedEl.closest('label')?.getAttribute('for');
|
||||
}
|
||||
|
||||
inputEl = document.getElementById(inputId);
|
||||
// Try to identify the input element (which may not be the clicked element)
|
||||
if (labelTags.includes(clickedTag)) {
|
||||
let inputId = null;
|
||||
if (clickedTag === "label") {
|
||||
inputId = clickedEl.getAttribute("for");
|
||||
} else {
|
||||
inputEl = clickedEl;
|
||||
inputId = clickedEl.closest("label")?.getAttribute("for");
|
||||
}
|
||||
|
||||
if (inputEl == null || !inputTags.includes(inputEl.nodeName.toLowerCase())) {
|
||||
return invalidElement;
|
||||
}
|
||||
inputEl = document.getElementById(inputId);
|
||||
} else {
|
||||
inputEl = clickedEl;
|
||||
}
|
||||
|
||||
for (const attr of attributes) {
|
||||
const attributeValue = inputEl.getAttribute(attr);
|
||||
const selector = '[' + attr + '="' + attributeValue + '"]';
|
||||
if (!isNullOrEmpty(attributeValue) && document.querySelectorAll(selector)?.length === 1) {
|
||||
return attributeValue;
|
||||
}
|
||||
if (inputEl == null || !inputTags.includes(inputEl.nodeName.toLowerCase())) {
|
||||
return invalidElement;
|
||||
}
|
||||
|
||||
for (const attr of attributes) {
|
||||
const attributeValue = inputEl.getAttribute(attr);
|
||||
const selector = "[" + attr + '="' + attributeValue + '"]';
|
||||
if (!isNullOrEmpty(attributeValue) && document.querySelectorAll(selector)?.length === 1) {
|
||||
return attributeValue;
|
||||
}
|
||||
return noUniqueIdentifier;
|
||||
}
|
||||
return noUniqueIdentifier;
|
||||
}
|
||||
|
||||
function isNullOrEmpty(s: string) {
|
||||
return s == null || s === '';
|
||||
return s == null || s === "";
|
||||
}
|
||||
|
||||
// We only have access to the element that's been clicked when the context menu is first opened.
|
||||
// Remember it for use later.
|
||||
document.addEventListener('contextmenu', event => {
|
||||
clickedEl = event.target as HTMLElement;
|
||||
document.addEventListener("contextmenu", (event) => {
|
||||
clickedEl = event.target as HTMLElement;
|
||||
});
|
||||
|
||||
// Runs when the 'Copy Custom Field Name' context menu item is actually clicked.
|
||||
chrome.runtime.onMessage.addListener(event => {
|
||||
if (event.command === 'getClickedElement') {
|
||||
const identifier = getClickedElementIdentifier();
|
||||
chrome.runtime.sendMessage({
|
||||
command: 'getClickedElementResponse',
|
||||
sender: 'contextMenuHandler',
|
||||
identifier: identifier,
|
||||
});
|
||||
}
|
||||
chrome.runtime.onMessage.addListener((event) => {
|
||||
if (event.command === "getClickedElement") {
|
||||
const identifier = getClickedElementIdentifier();
|
||||
chrome.runtime.sendMessage({
|
||||
command: "getClickedElementResponse",
|
||||
sender: "contextMenuHandler",
|
||||
identifier: identifier,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,30 +1,37 @@
|
||||
window.addEventListener('message', event => {
|
||||
if (event.source !== window)
|
||||
return;
|
||||
window.addEventListener(
|
||||
"message",
|
||||
(event) => {
|
||||
if (event.source !== window) return;
|
||||
|
||||
if (event.data.command && (event.data.command === 'authResult')) {
|
||||
chrome.runtime.sendMessage({
|
||||
command: event.data.command,
|
||||
code: event.data.code,
|
||||
state: event.data.state,
|
||||
referrer: event.source.location.hostname,
|
||||
});
|
||||
if (event.data.command && event.data.command === "authResult") {
|
||||
chrome.runtime.sendMessage({
|
||||
command: event.data.command,
|
||||
code: event.data.code,
|
||||
state: event.data.state,
|
||||
referrer: event.source.location.hostname,
|
||||
});
|
||||
}
|
||||
|
||||
if (event.data.command && (event.data.command === 'webAuthnResult')) {
|
||||
chrome.runtime.sendMessage({
|
||||
command: event.data.command,
|
||||
data: event.data.data,
|
||||
remember: event.data.remember,
|
||||
referrer: event.source.location.hostname,
|
||||
});
|
||||
if (event.data.command && event.data.command === "webAuthnResult") {
|
||||
chrome.runtime.sendMessage({
|
||||
command: event.data.command,
|
||||
data: event.data.data,
|
||||
remember: event.data.remember,
|
||||
referrer: event.source.location.hostname,
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
const forwardCommands = ['promptForLogin', 'addToLockedVaultPendingNotifications', 'unlockCompleted'];
|
||||
const forwardCommands = [
|
||||
"promptForLogin",
|
||||
"addToLockedVaultPendingNotifications",
|
||||
"unlockCompleted",
|
||||
];
|
||||
|
||||
chrome.runtime.onMessage.addListener(event => {
|
||||
if (forwardCommands.includes(event.command)) {
|
||||
chrome.runtime.sendMessage(event);
|
||||
}
|
||||
chrome.runtime.onMessage.addListener((event) => {
|
||||
if (forwardCommands.includes(event.command)) {
|
||||
chrome.runtime.sendMessage(event);
|
||||
}
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,50 +1,52 @@
|
||||
import * as Mousetrap from 'mousetrap';
|
||||
import * as Mousetrap from "mousetrap";
|
||||
|
||||
document.addEventListener('DOMContentLoaded', event => {
|
||||
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||
navigator.userAgent.indexOf('Chrome') === -1;
|
||||
const isVivaldi = !isSafari && navigator.userAgent.indexOf(' Vivaldi/') !== -1;
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
const isSafari =
|
||||
typeof safari !== "undefined" &&
|
||||
navigator.userAgent.indexOf(" Safari/") !== -1 &&
|
||||
navigator.userAgent.indexOf("Chrome") === -1;
|
||||
const isVivaldi = !isSafari && navigator.userAgent.indexOf(" Vivaldi/") !== -1;
|
||||
|
||||
if (!isSafari && !isVivaldi) {
|
||||
return;
|
||||
}
|
||||
if (!isSafari && !isVivaldi) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSafari && (window as any).__bitwardenFrameId == null) {
|
||||
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||
}
|
||||
if (isSafari && (window as any).__bitwardenFrameId == null) {
|
||||
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||
}
|
||||
|
||||
Mousetrap.prototype.stopCallback = () => {
|
||||
return false;
|
||||
};
|
||||
Mousetrap.prototype.stopCallback = () => {
|
||||
return false;
|
||||
};
|
||||
|
||||
let autofillCommand = ['mod+shift+l'];
|
||||
if (isSafari) {
|
||||
autofillCommand = ['mod+\\', 'mod+8', 'mod+shift+p'];
|
||||
}
|
||||
Mousetrap.bind(autofillCommand, () => {
|
||||
sendMessage('autofill_login');
|
||||
let autofillCommand = ["mod+shift+l"];
|
||||
if (isSafari) {
|
||||
autofillCommand = ["mod+\\", "mod+8", "mod+shift+p"];
|
||||
}
|
||||
Mousetrap.bind(autofillCommand, () => {
|
||||
sendMessage("autofill_login");
|
||||
});
|
||||
|
||||
if (isSafari) {
|
||||
Mousetrap.bind("mod+shift+y", () => {
|
||||
sendMessage("open_popup");
|
||||
});
|
||||
|
||||
if (isSafari) {
|
||||
Mousetrap.bind('mod+shift+y', () => {
|
||||
sendMessage('open_popup');
|
||||
});
|
||||
Mousetrap.bind("mod+shift+s", () => {
|
||||
sendMessage("lock_vault");
|
||||
});
|
||||
} else {
|
||||
Mousetrap.bind("mod+shift+9", () => {
|
||||
sendMessage("generate_password");
|
||||
});
|
||||
}
|
||||
|
||||
Mousetrap.bind('mod+shift+s', () => {
|
||||
sendMessage('lock_vault');
|
||||
});
|
||||
} else {
|
||||
Mousetrap.bind('mod+shift+9', () => {
|
||||
sendMessage('generate_password');
|
||||
});
|
||||
}
|
||||
function sendMessage(shortcut: string) {
|
||||
const msg: any = {
|
||||
command: "keyboardShortcutTriggered",
|
||||
shortcut: shortcut,
|
||||
};
|
||||
|
||||
function sendMessage(shortcut: string) {
|
||||
const msg: any = {
|
||||
command: 'keyboardShortcutTriggered',
|
||||
shortcut: shortcut,
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user