/* Copyright (C) 2013-2020 Grégory Soutadé This file is part of gPass. gPass is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. gPass is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with gPass. If not, see . */ var gpass_enabled = true; function _notification(message, data) { if (message !== data) message += data; options = { type: "basic", title : "gPass", message : message, iconUrl: browser.runtime.getURL("icons/gpass_icon_64.png") }; browser.notifications.create(options).then( function created(notification_id) { window.setTimeout(function() { browser.notifications.clear(notification_id); }, 2000); } ); } function _add_name(logins, name) { for(var i=0; i && type_filters.push("text"); type_filters.push("email"); if (all_logins) logins = try_get_name(fields, type_filters, true); else { // Get all other fields except text, email and password type_filters.push("password"); type_filters.push("hidden"); logins = try_get_name(fields, type_filters, false); } return logins; } function on_focus(e) { if (!gpass_enabled) return; var logins = get_logins(this.form, true); var all_logins = get_logins(this.form, false); if (logins.length || all_logins.length) { parameters = { type:"update_icon", icon_id:GPASS_ICON.ACTIVATED, }; browser.runtime.sendMessage(parameters, {}); } } function on_blur(e) { if (!gpass_enabled) return; parameters = { type:"update_icon", icon_id:GPASS_ICON.NORMAL, }; browser.runtime.sendMessage(parameters, {}); } function on_sumbit(e) { var form = this; var fields = form.getElementsByTagName("input"); var domain = form.ownerDocument.baseURI; var password_computed = false; debug("on_submit"); logins = get_logins(form, true); all_logins = get_logins(form, false); if (!logins.length) logins = all_logins; e.preventDefault(); // Look for for (var i=0; i && type_filters.push("text"); type_filters.push("email"); logins = try_get_name(fields, type_filters, true); if (logins.length == 1) sendResponse(logins[0]); else sendResponse(""); } else sendResponse(""); } else if (request.type == "setPassword") { debug("setPassword"); var response = ""; if (managed_forms.length == 1) { fields = managed_forms[0].getElementsByTagName("input"); password_field = null; for (a=0; a