Merge pull request #2942 from kepi/fix/pfill_visible_input
password_fill: Stop filling username to invisible input fields
This commit is contained in:
commit
ee147bb327
@ -327,6 +327,17 @@ open_entry "$file"
|
|||||||
|
|
||||||
js() {
|
js() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
function isVisible(elem) {
|
||||||
|
var style = elem.ownerDocument.defaultView.getComputedStyle(elem, null);
|
||||||
|
|
||||||
|
if (style.getPropertyValue("visibility") !== "visible" ||
|
||||||
|
style.getPropertyValue("display") === "none" ||
|
||||||
|
style.getPropertyValue("opacity") === "0") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return elem.offsetWidth > 0 && elem.offsetHeight > 0;
|
||||||
|
};
|
||||||
function hasPasswordField(form) {
|
function hasPasswordField(form) {
|
||||||
var inputs = form.getElementsByTagName("input");
|
var inputs = form.getElementsByTagName("input");
|
||||||
for (var j = 0; j < inputs.length; j++) {
|
for (var j = 0; j < inputs.length; j++) {
|
||||||
@ -341,7 +352,7 @@ cat <<EOF
|
|||||||
var inputs = form.getElementsByTagName("input");
|
var inputs = form.getElementsByTagName("input");
|
||||||
for (var j = 0; j < inputs.length; j++) {
|
for (var j = 0; j < inputs.length; j++) {
|
||||||
var input = inputs[j];
|
var input = inputs[j];
|
||||||
if (input.type == "text" || input.type == "email") {
|
if (isVisible(input) && (input.type == "text" || input.type == "email")) {
|
||||||
input.focus();
|
input.focus();
|
||||||
input.value = "$(javascript_escape "${username}")";
|
input.value = "$(javascript_escape "${username}")";
|
||||||
input.blur();
|
input.blur();
|
||||||
|
Loading…
Reference in New Issue
Block a user