1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-24 16:49:26 +01:00

refactoring out minified code for autofill content script

This commit is contained in:
Kyle Spearrin 2017-01-19 19:16:13 -05:00
parent 0bd77352b0
commit 55afdf70f6

View File

@ -1,4 +1,4 @@
!(function() {
!(function () {
/*
1Password Extension
@ -28,55 +28,798 @@
SOFTWARE.
*/
// MODIFICATIONS: populate isFirefox. Remove isChrome and isSafari since they are not used.
/*
MODIFICATIONS FROM ORIGINAL
1. Populate isFirefox
2. Remove isChrome and isSafari since they are not used.
3. Unminify and format to meet Mozilla review requirements.
*/
function collect(document, undefined) {
var isFirefox = navigator.userAgent.indexOf('Firefox') !== -1 || navigator.userAgent.indexOf('Gecko/') !== -1;
document.elementsByOPID={};document.addEventListener('input',function(b){!1!==b.a&&'input'===b.target.tagName.toLowerCase()&&(b.target.dataset['com.agilebits.onepassword.userEdited']='yes')},!0);
function q(b,d){function f(a,e){var c=a[e];if('string'==typeof c)return c;c=a.getAttribute(e);return'string'==typeof c?c:null}function h(a,e){if(-1===['text','password'].indexOf(e.type.toLowerCase())||!(m.test(a.value)||m.test(a.htmlID)||m.test(a.htmlName)||m.test(a.placeholder)||m.test(a['label-tag'])||m.test(a['label-data'])||m.test(a['label-aria'])))return!1;if(!a.visible)return!0;if('password'==e.type.toLowerCase())return!1;var c=e.type;v(e,!0);return c!==e.type}function n(a){switch(p(a.type)){case 'checkbox':return a.checked?
'✓':'';case 'hidden':a=a.value;if(!a||'number'!=typeof a.length)return'';254<a.length&&(a=a.substr(0,254)+'...SNIPPED');return a;default:return a.value}}function l(a){return a.options?(a=Array.prototype.slice.call(a.options).map(function(a){var c=a.text,c=c?p(c).replace(/\\s/mg,'').replace(/[~`!@$%^&*()\\-_+=:;'\"\\[\\]|\\\\,<.>\\?]/mg,''):null;return[c?c:null,a.value]}),{options:a}):null}function r(a){var e;for(a=a.parentElement||a.parentNode;a&&'td'!=p(a.tagName);)a=a.parentElement||a.parentNode;if(!a||
void 0===a)return null;e=a.parentElement||a.parentNode;if('tr'!=e.tagName.toLowerCase())return null;e=e.previousElementSibling;if(!e||'tr'!=(e.tagName+'').toLowerCase()||e.cells&&a.cellIndex>=e.cells.length)return null;a=e.cells[a.cellIndex];a=a.textContent||a.innerText;return a=x(a)}function s(a){var e,c=[];if(a.labels&&a.labels.length&&0<a.labels.length)c=Array.prototype.slice.call(a.labels);else{a.id&&(c=c.concat(Array.prototype.slice.call(w(b,'label[for='+JSON.stringify(a.id)+']'))));if(a.name){e=
w(b,'label[for='+JSON.stringify(a.name)+']');for(var f=0;f<e.length;f++)-1===c.indexOf(e[f])&&c.push(e[f])}for(e=a;e&&e!=b;e=e.parentNode)'label'===p(e.tagName)&&-1===c.indexOf(e)&&c.push(e)}0===c.length&&(e=a.parentNode,'dd'===e.tagName.toLowerCase()&&null!==e.previousElementSibling&&'dt'===e.previousElementSibling.tagName.toLowerCase()&&c.push(e.previousElementSibling));return 0<c.length?c.map(function(a){return(a.textContent||a.innerText).replace(/^\\s+/,'').replace(/\\s+$/,'').replace('\\n','').replace(/\\s{2,}/,
' ')}).join(''):null}function g(a,e,c,b){void 0!==b&&b===c||null===c||void 0===c||(a[e]=c)}function p(a){return'string'===typeof a?a.toLowerCase():(''+a).toLowerCase()}function w(a,b){var c=[];try{c=a.querySelectorAll(b)}catch(f){}return c}var t=b.defaultView?b.defaultView:window,m=RegExp('((\\\\b|_|-)pin(\\\\b|_|-)|password|passwort|kennwort|(\\\\b|_|-)passe(\\\\b|_|-)|contraseña|senha|密码|adgangskode|hasło|wachtwoord)','i'),u=Array.prototype.slice.call(w(b,'form')).map(function(a,b){var c={},d='__form__'+
b;a.opid=d;c.opid=d;g(c,'htmlName',f(a,'name'));g(c,'htmlID',f(a,'id'));d=f(a,'action');d=new URL(d,window.location.href);g(c,'htmlAction',d?d.href:null);g(c,'htmlMethod',f(a,'method'));return c}),E=Array.prototype.slice.call(y(b)).map(function(a,e){var c={},d='__'+e,k=-1==a.maxLength?999:a.maxLength;if(!k||'number'===typeof k&&isNaN(k))k=999;b.elementsByOPID[d]=a;a.opid=d;c.opid=d;c.elementNumber=e;g(c,'maxLength',Math.min(k,999),999);c.visible=z(a);c.viewable=A(a);g(c,'htmlID',f(a,'id'));g(c,'htmlName',
f(a,'name'));g(c,'htmlClass',f(a,'class'));g(c,'tabindex',f(a,'tabindex'));g(c,'title',f(a,'title'));g(c,'userEdited',!!a.dataset['com.agilebits.onepassword.userEdited']);if('hidden'!=p(a.type)){g(c,'label-tag',s(a));g(c,'label-data',f(a,'data-label'));g(c,'label-aria',f(a,'aria-label'));g(c,'label-top',r(a));d=[];for(k=a;k&&k.nextSibling;){k=k.nextSibling;if(B(k))break;C(d,k)}g(c,'label-right',d.join(''));d=[];D(a,d);d=d.reverse().join('');g(c,'label-left',d);g(c,'placeholder',f(a,'placeholder'))}g(c,
'rel',f(a,'rel'));g(c,'type',p(f(a,'type')));g(c,'value',n(a));g(c,'checked',a.checked,!1);g(c,'autoCompleteType',a.getAttribute('x-autocompletetype')||a.getAttribute('autocompletetype')||a.getAttribute('autocomplete'),'off');g(c,'disabled',a.disabled);g(c,'readonly',a.b||a.readOnly);g(c,'selectInfo',l(a));g(c,'aria-hidden','true'==a.getAttribute('aria-hidden'),!1);g(c,'aria-disabled','true'==a.getAttribute('aria-disabled'),!1);g(c,'aria-haspopup','true'==a.getAttribute('aria-haspopup'),!1);g(c,'data-unmasked',
a.dataset.unmasked);g(c,'data-stripe',f(a,'data-stripe'));g(c,'onepasswordFieldType',a.dataset.onepasswordFieldType||a.type);g(c,'onepasswordDesignation',a.dataset.onepasswordDesignation);g(c,'onepasswordSignInUrl',a.dataset.onepasswordSignInUrl);g(c,'onepasswordSectionTitle',a.dataset.onepasswordSectionTitle);g(c,'onepasswordSectionFieldKind',a.dataset.onepasswordSectionFieldKind);g(c,'onepasswordSectionFieldTitle',a.dataset.onepasswordSectionFieldTitle);g(c,'onepasswordSectionFieldValue',a.dataset.onepasswordSectionFieldValue);
a.form&&(c.form=f(a.form,'opid'));g(c,'fakeTested',h(c,a),!1);return c});E.filter(function(a){return a.fakeTested}).forEach(function(a){var e=b.elementsByOPID[a.opid];e.getBoundingClientRect();var c=e.value;!e||e&&'function'!==typeof e.click||e.click();v(e,!1);e.dispatchEvent(F(e,'keydown'));e.dispatchEvent(F(e,'keypress'));e.dispatchEvent(F(e,'keyup'));e.value!==c&&(e.value=c);e.click&&e.click();a.postFakeTestVisible=z(e);a.postFakeTestViewable=A(e);a.postFakeTestType=e.type;a=e.value;var c=e.ownerDocument.createEvent('HTMLEvents'),
d=e.ownerDocument.createEvent('HTMLEvents');e.dispatchEvent(F(e,'keydown'));e.dispatchEvent(F(e,'keypress'));e.dispatchEvent(F(e,'keyup'));d.initEvent('input',!0,!0);e.dispatchEvent(d);c.initEvent('change',!0,!0);e.dispatchEvent(c);e.blur();e.value!==a&&(e.value=a)});t={documentUUID:d,title:b.title,url:t.location.href,documentUrl:b.location.href,tabUrl:t.location.href,forms:function(a){var b={};a.forEach(function(a){b[a.opid]=a});return b}(u),fields:E,collectedTimestamp:(new Date).getTime()};(u=document.querySelector('[data-onepassword-title]'))&&
u.dataset[DISPLAY_TITLE_ATTRIBUE]&&(t.displayTitle=u.dataset.onepasswordTitle);return t};document.elementForOPID=G;function F(b,d){var f;isFirefox?(f=document.createEvent('KeyboardEvent'),f.initKeyEvent(d,!0,!1,null,!1,!1,!1,!1,0,0)):(f=b.ownerDocument.createEvent('Events'),f.initEvent(d,!0,!1),f.charCode=0,f.keyCode=0,f.which=0,f.srcElement=b,f.target=b);return f}window.LOGIN_TITLES=[/^\\W*log\\W*[oi]n\\W*$/i,/log\\W*[oi]n (?:securely|now)/i,/^\\W*sign\\W*[oi]n\\W*$/i,'continue','submit','weiter','accès','вход','connexion','entrar','anmelden','accedi','valider','登录','लॉग इन करें','change password'];
window.LOGIN_RED_HERRING_TITLES=['already have an account','sign in with'];window.REGISTER_TITLES='register;sign up;signup;join;create my account;регистрация;inscription;regístrate;cadastre-se;registrieren;registrazione;注册;साइन अप करें'.split(';');window.SEARCH_TITLES='search find поиск найти искать recherche suchen buscar suche ricerca procurar 検索'.split(' ');window.FORGOT_PASSWORD_TITLES='forgot geändert vergessen hilfe changeemail español'.split(' ');
window.REMEMBER_ME_TITLES=['remember me','rememberme','keep me signed in'];window.BACK_TITLES=['back','назад'];function x(b){var d=null;b&&(d=b.replace(/^\\s+|\\s+$|\\r?\\n.*$/mg,''),d=0<d.length?d:null);return d}function C(b,d){var f;f='';3===d.nodeType?f=d.nodeValue:1===d.nodeType&&(f=d.textContent||d.innerText);(f=x(f))&&b.push(f)}
function B(b){var d;b&&void 0!==b?(d='select option input form textarea button table iframe body head script'.split(' '),b?(b=b?(b.tagName||'').toLowerCase():'',d=d.constructor==Array?0<=d.indexOf(b):b===d):d=!1):d=!0;return d}
function D(b,d,f){var h;for(f||(f=0);b&&b.previousSibling;){b=b.previousSibling;if(B(b))return;C(d,b)}if(b&&0===d.length){for(h=null;!h;){b=b.parentElement||b.parentNode;if(!b)return;for(h=b.previousSibling;h&&!B(h)&&h.lastChild;)h=h.lastChild}B(h)||(C(d,h),0===d.length&&D(h,d,f+1))}}
function z(b){var d=b;b=(b=b.ownerDocument)?b.defaultView:{};for(var f;d&&d!==document;){f=b.getComputedStyle?b.getComputedStyle(d,null):d.style;if(!f)return!0;if('none'===f.display||'hidden'==f.visibility)return!1;d=d.parentNode}return d===document}
function A(b){var d=b.ownerDocument.documentElement,f=b.getBoundingClientRect(),h=d.scrollWidth,n=d.scrollHeight,l=f.left-d.clientLeft,d=f.top-d.clientTop,r;if(!z(b)||!b.offsetParent||10>b.clientWidth||10>b.clientHeight)return!1;var s=b.getClientRects();if(0===s.length)return!1;for(var g=0;g<s.length;g++)if(r=s[g],r.left>h||0>r.right)return!1;if(0>l||l>h||0>d||d>n)return!1;for(f=b.ownerDocument.elementFromPoint(l+(f.right>window.innerWidth?(window.innerWidth-l)/2:f.width/2),d+(f.bottom>window.innerHeight?
(window.innerHeight-d)/2:f.height/2));f&&f!==b&&f!==document;){if(f.tagName&&'string'===typeof f.tagName&&'label'===f.tagName.toLowerCase()&&b.labels&&0<b.labels.length)return 0<=Array.prototype.slice.call(b.labels).indexOf(f);f=f.parentNode}return f===b}
function G(b){var d;if(void 0===b||null===b)return null;try{var f=Array.prototype.slice.call(y(document)),h=f.filter(function(d){return d.opid==b});if(0<h.length)d=h[0],1<h.length&&console.warn('More than one element found with opid '+b);else{var n=parseInt(b.split('__')[1],10);isNaN(n)||(d=f[n])}}catch(l){console.error('An unexpected error occurred: '+l)}finally{return d}};function y(b){var d=[];try{d=b.querySelectorAll('input, select, button')}catch(f){}return d}function v(b,d){if(d){var f=b.value;b.focus();b.value!==f&&(b.value=f)}else b.focus()};
return JSON.stringify(q(document, 'oneshotUUID'));
document.elementsByOPID = {};
document.addEventListener('input', function (canuf) {
false !== canuf.a && 'input' === canuf.target.tagName.toLowerCase() && (canuf.target.dataset['com.agilebits.onepassword.userEdited'] = 'yes');
}, true);
function sasrie(theDoc, oneShotId) {
function jihid(noosun, otab) {
var asril = noosun[otab];
if ('string' == typeof asril) {
return asril;
}
asril = noosun.getAttribute(otab);
return 'string' == typeof asril ? asril : null;
}
function tepe(fige, nihat) {
if (-1 === ['text', 'password'].indexOf(nihat.type.toLowerCase()) || !(passwordRegEx.test(fige.value) || passwordRegEx.test(fige.htmlID) || passwordRegEx.test(fige.htmlName) || passwordRegEx.test(fige.placeholder) || passwordRegEx.test(fige['label-tag']) || passwordRegEx.test(fige['label-data']) || passwordRegEx.test(fige['label-aria']))) {
return false;
}
if (!fige.visible) {
return true;
}
if ('password' == nihat.type.toLowerCase()) {
return false;
}
var jeko = nihat.type;
jesceln(nihat, true);
return jeko !== nihat.type;
}
function sumu(bafo) {
switch (toLowerString(bafo.type)) {
case 'checkbox':
return bafo.checked ? '✓' : '';
case 'hidden':
bafo = bafo.value;
if (!bafo || 'number' != typeof bafo.length) {
return '';
}
254 < bafo.length && (bafo = bafo.substr(0, 254) + '...SNIPPED');
return bafo;
default:
return bafo.value;
}
}
function muri(goofu) {
return goofu.options ? (goofu = Array.prototype.slice.call(goofu.options).map(function (luebi) {
var cituen = luebi.text, cituen = cituen ? toLowerString(cituen).replace(/\\s/gm, '').replace(/[~`!@$%^&*()\\-_+=:;'\"\\[\\]|\\\\,<.>\\?]/gm, '') : null;
return [cituen ? cituen : null, luebi.value];
}), {
options: goofu
}) : null;
}
function cobu(mickuf) {
var rana;
for (mickuf = mickuf.parentElement || mickuf.parentNode; mickuf && 'td' != toLowerString(mickuf.tagName) ;) {
mickuf = mickuf.parentElement || mickuf.parentNode;
}
if (!mickuf || void 0 === mickuf) {
return null;
}
rana = mickuf.parentElement || mickuf.parentNode;
if ('tr' != rana.tagName.toLowerCase()) {
return null;
}
rana = rana.previousElementSibling;
if (!rana || 'tr' != (rana.tagName + '').toLowerCase() || rana.cells && mickuf.cellIndex >= rana.cells.length) {
return null;
}
mickuf = rana.cells[mickuf.cellIndex];
mickuf = mickuf.textContent || mickuf.innerText;
return mickuf = loopi(mickuf);
}
function kasu(prifue) {
var jefu, hage = [];
if (prifue.labels && prifue.labels.length && 0 < prifue.labels.length) {
hage = Array.prototype.slice.call(prifue.labels);
} else {
prifue.id && (hage = hage.concat(Array.prototype.slice.call(queryDoc(theDoc, 'label[for=' + JSON.stringify(prifue.id) + ']'))));
if (prifue.name) {
jefu = queryDoc(theDoc, 'label[for=' + JSON.stringify(prifue.name) + ']');
for (var dilaf = 0; dilaf < jefu.length; dilaf++) {
-1 === hage.indexOf(jefu[dilaf]) && hage.push(jefu[dilaf]);
}
}
for (jefu = prifue; jefu && jefu != theDoc; jefu = jefu.parentNode) {
'label' === toLowerString(jefu.tagName) && -1 === hage.indexOf(jefu) && hage.push(jefu);
}
}
0 === hage.length && (jefu = prifue.parentNode, 'dd' === jefu.tagName.toLowerCase() && null !== jefu.previousElementSibling && 'dt' === jefu.previousElementSibling.tagName.toLowerCase() && hage.push(jefu.previousElementSibling));
return 0 < hage.length ? hage.map(function (noquo) {
return (noquo.textContent || noquo.innerText).replace(/^\\s+/, '').replace(/\\s+$/, '').replace('\\n', '').replace(/\\s{2,}/, ' ');
}).join('') : null;
}
function etit(kisa, puju, lofes, aynem) {
void 0 !== aynem && aynem === lofes || null === lofes || void 0 === lofes || (kisa[puju] = lofes);
}
function toLowerString(s) {
return 'string' === typeof s ? s.toLowerCase() : ('' + s).toLowerCase();
}
function queryDoc(doc, query) {
var els = [];
try {
els = doc.querySelectorAll(query);
} catch (e) { }
return els;
}
var theView = theDoc.defaultView ? theDoc.defaultView : window,
passwordRegEx = RegExp('((\\\\b|_|-)pin(\\\\b|_|-)|password|passwort|kennwort|(\\\\b|_|-)passe(\\\\b|_|-)|contraseña|senha|密码|adgangskode|hasło|wachtwoord)', 'i');
var theTitle = Array.prototype.slice.call(queryDoc(theDoc, 'form')).map(function (formEl, elIndex) {
var op = {},
formOpId = '__form__' + elIndex;
formEl.opid = formOpId;
op.opid = formOpId;
etit(op, 'htmlName', jihid(formEl, 'name'));
etit(op, 'htmlID', jihid(formEl, 'id'));
formOpId = jihid(formEl, 'action');
formOpId = new URL(formOpId, window.location.href);
etit(op, 'htmlAction', formOpId ? formOpId.href : null);
etit(op, 'htmlMethod', jihid(formEl, 'method'));
return op;
});
var theFields = Array.prototype.slice.call(getFormElements(theDoc)).map(function (tadkak, shoho) {
var neref = {}, bosna = '__' + shoho, steyquif = -1 == tadkak.maxLength ? 999 : tadkak.maxLength;
if (!steyquif || 'number' === typeof steyquif && isNaN(steyquif)) {
steyquif = 999;
}
theDoc.elementsByOPID[bosna] = tadkak;
tadkak.opid = bosna;
neref.opid = bosna;
neref.elementNumber = shoho;
etit(neref, 'maxLength', Math.min(steyquif, 999), 999);
neref.visible = ciquod(tadkak);
neref.viewable = blekey(tadkak);
etit(neref, 'htmlID', jihid(tadkak, 'id'));
etit(neref, 'htmlName', jihid(tadkak, 'name'));
etit(neref, 'htmlClass', jihid(tadkak, 'class'));
etit(neref, 'tabindex', jihid(tadkak, 'tabindex'));
etit(neref, 'title', jihid(tadkak, 'title'));
etit(neref, 'userEdited', !!tadkak.dataset['com.agilebits.onepassword.userEdited']);
if ('hidden' != toLowerString(tadkak.type)) {
etit(neref, 'label-tag', kasu(tadkak));
etit(neref, 'label-data', jihid(tadkak, 'data-label'));
etit(neref, 'label-aria', jihid(tadkak, 'aria-label'));
etit(neref, 'label-top', cobu(tadkak));
bosna = [];
for (steyquif = tadkak; steyquif && steyquif.nextSibling;) {
steyquif = steyquif.nextSibling;
if (quernaln(steyquif)) {
break;
}
queka(bosna, steyquif);
}
etit(neref, 'label-right', bosna.join(''));
bosna = [];
bozoum(tadkak, bosna);
bosna = bosna.reverse().join('');
etit(neref, 'label-left', bosna);
etit(neref, 'placeholder', jihid(tadkak, 'placeholder'));
}
etit(neref, 'rel', jihid(tadkak, 'rel'));
etit(neref, 'type', toLowerString(jihid(tadkak, 'type')));
etit(neref, 'value', sumu(tadkak));
etit(neref, 'checked', tadkak.checked, false);
etit(neref, 'autoCompleteType', tadkak.getAttribute('x-autocompletetype') || tadkak.getAttribute('autocompletetype') || tadkak.getAttribute('autocomplete'), 'off');
etit(neref, 'disabled', tadkak.disabled);
etit(neref, 'readonly', tadkak.b || tadkak.readOnly);
etit(neref, 'selectInfo', muri(tadkak));
etit(neref, 'aria-hidden', 'true' == tadkak.getAttribute('aria-hidden'), false);
etit(neref, 'aria-disabled', 'true' == tadkak.getAttribute('aria-disabled'), false);
etit(neref, 'aria-haspopup', 'true' == tadkak.getAttribute('aria-haspopup'), false);
etit(neref, 'data-unmasked', tadkak.dataset.unmasked);
etit(neref, 'data-stripe', jihid(tadkak, 'data-stripe'));
etit(neref, 'onepasswordFieldType', tadkak.dataset.onepasswordFieldType || tadkak.type);
etit(neref, 'onepasswordDesignation', tadkak.dataset.onepasswordDesignation);
etit(neref, 'onepasswordSignInUrl', tadkak.dataset.onepasswordSignInUrl);
etit(neref, 'onepasswordSectionTitle', tadkak.dataset.onepasswordSectionTitle);
etit(neref, 'onepasswordSectionFieldKind', tadkak.dataset.onepasswordSectionFieldKind);
etit(neref, 'onepasswordSectionFieldTitle', tadkak.dataset.onepasswordSectionFieldTitle);
etit(neref, 'onepasswordSectionFieldValue', tadkak.dataset.onepasswordSectionFieldValue);
tadkak.form && (neref.form = jihid(tadkak.form, 'opid'));
etit(neref, 'fakeTested', tepe(neref, tadkak), false);
return neref;
});
theFields.filter(function (hefik) {
return hefik.fakeTested;
}).forEach(function (kukip) {
var cisuf = theDoc.elementsByOPID[kukip.opid];
cisuf.getBoundingClientRect();
var jeechgan = cisuf.value;
!cisuf || cisuf && 'function' !== typeof cisuf.click || cisuf.click();
jesceln(cisuf, false);
cisuf.dispatchEvent(guna(cisuf, 'keydown'));
cisuf.dispatchEvent(guna(cisuf, 'keypress'));
cisuf.dispatchEvent(guna(cisuf, 'keyup'));
cisuf.value !== jeechgan && (cisuf.value = jeechgan);
cisuf.click && cisuf.click();
kukip.postFakeTestVisible = ciquod(cisuf);
kukip.postFakeTestViewable = blekey(cisuf);
kukip.postFakeTestType = cisuf.type;
kukip = cisuf.value;
var jeechgan = cisuf.ownerDocument.createEvent('HTMLEvents'), jalue = cisuf.ownerDocument.createEvent('HTMLEvents');
cisuf.dispatchEvent(guna(cisuf, 'keydown'));
cisuf.dispatchEvent(guna(cisuf, 'keypress'));
cisuf.dispatchEvent(guna(cisuf, 'keyup'));
jalue.initEvent('input', true, true);
cisuf.dispatchEvent(jalue);
jeechgan.initEvent('change', true, true);
cisuf.dispatchEvent(jeechgan);
cisuf.blur();
cisuf.value !== kukip && (cisuf.value = kukip);
});
var pageDetails = {
documentUUID: oneShotId,
title: theDoc.title,
url: theView.location.href,
documentUrl: theDoc.location.href,
tabUrl: theView.location.href,
forms: function (basas) {
var histstap = {};
basas.forEach(function (quavu) {
histstap[quavu.opid] = quavu;
});
return histstap;
}(theTitle),
fields: theFields,
collectedTimestamp: new Date().getTime()
};
// get proper page title. maybe they are using the special meta tag?
theTitle = document.querySelector('[data-onepassword-title]')
if (theTitle && theTitle.dataset[DISPLAY_TITLE_ATTRIBUE]) {
pageDetails.displayTitle = theTitle.dataset.onepasswordTitle;
}
return pageDetails;
}
document.elementForOPID = jasu;
function guna(kedol, fonor) {
var quebo;
isFirefox ? (quebo = document.createEvent('KeyboardEvent'), quebo.initKeyEvent(fonor, true, false, null, false, false, false, false, 0, 0)) : (quebo = kedol.ownerDocument.createEvent('Events'),
quebo.initEvent(fonor, true, false), quebo.charCode = 0, quebo.keyCode = 0, quebo.which = 0,
quebo.srcElement = kedol, quebo.target = kedol);
return quebo;
}
window.LOGIN_TITLES = [/^\\W*log\\W*[oi]n\\W*$/i, /log\\W*[oi]n (?:securely|now)/i, /^\\W*sign\\W*[oi]n\\W*$/i, 'continue', 'submit', 'weiter', 'accès', 'вход', 'connexion', 'entrar', 'anmelden', 'accedi', 'valider', '登录', 'लॉग इन करें', 'change password'];
window.LOGIN_RED_HERRING_TITLES = ['already have an account', 'sign in with'];
window.REGISTER_TITLES = 'register;sign up;signup;join;create my account;регистрация;inscription;regístrate;cadastre-se;registrieren;registrazione;注册;साइन अप करें'.split(';');
window.SEARCH_TITLES = 'search find поиск найти искать recherche suchen buscar suche ricerca procurar 検索'.split(' ');
window.FORGOT_PASSWORD_TITLES = 'forgot geändert vergessen hilfe changeemail español'.split(' ');
window.REMEMBER_ME_TITLES = ['remember me', 'rememberme', 'keep me signed in'];
window.BACK_TITLES = ['back', 'назад'];
function loopi(segu) {
var bitou = null;
segu && (bitou = segu.replace(/^\\s+|\\s+$|\\r?\\n.*$/gm, ''), bitou = 0 < bitou.length ? bitou : null);
return bitou;
}
function queka(tigap, niela) {
var jahe;
jahe = '';
3 === niela.nodeType ? jahe = niela.nodeValue : 1 === niela.nodeType && (jahe = niela.textContent || niela.innerText);
(jahe = loopi(jahe)) && tigap.push(jahe);
}
function quernaln(ukag) {
var relu;
ukag && void 0 !== ukag ? (relu = 'select option input form textarea button table iframe body head script'.split(' '),
ukag ? (ukag = ukag ? (ukag.tagName || '').toLowerCase() : '', relu = relu.constructor == Array ? 0 <= relu.indexOf(ukag) : ukag === relu) : relu = false) : relu = true;
return relu;
}
function bozoum(edpuk, uday, siru) {
var quoto;
for (siru || (siru = 0) ; edpuk && edpuk.previousSibling;) {
edpuk = edpuk.previousSibling;
if (quernaln(edpuk)) {
return;
}
queka(uday, edpuk);
}
if (edpuk && 0 === uday.length) {
for (quoto = null; !quoto;) {
edpuk = edpuk.parentElement || edpuk.parentNode;
if (!edpuk) {
return;
}
for (quoto = edpuk.previousSibling; quoto && !quernaln(quoto) && quoto.lastChild;) {
quoto = quoto.lastChild;
}
}
quernaln(quoto) || (queka(uday, quoto), 0 === uday.length && bozoum(quoto, uday, siru + 1));
}
}
function ciquod(hieku) {
var liji = hieku;
hieku = (hieku = hieku.ownerDocument) ? hieku.defaultView : {};
for (var teesi; liji && liji !== document;) {
teesi = hieku.getComputedStyle ? hieku.getComputedStyle(liji, null) : liji.style;
if (!teesi) {
return true;
}
if ('none' === teesi.display || 'hidden' == teesi.visibility) {
return false;
}
liji = liji.parentNode;
}
return liji === document;
}
function blekey(coufi) {
var pudu = coufi.ownerDocument.documentElement, muma = coufi.getBoundingClientRect(), gubuech = pudu.scrollWidth, kosri = pudu.scrollHeight, quophe = muma.left - pudu.clientLeft, pudu = muma.top - pudu.clientTop, temton;
if (!ciquod(coufi) || !coufi.offsetParent || 10 > coufi.clientWidth || 10 > coufi.clientHeight) {
return false;
}
var aley = coufi.getClientRects();
if (0 === aley.length) {
return false;
}
for (var sehi = 0; sehi < aley.length; sehi++) {
if (temton = aley[sehi], temton.left > gubuech || 0 > temton.right) {
return false;
}
}
if (0 > quophe || quophe > gubuech || 0 > pudu || pudu > kosri) {
return false;
}
for (muma = coufi.ownerDocument.elementFromPoint(quophe + (muma.right > window.innerWidth ? (window.innerWidth - quophe) / 2 : muma.width / 2), pudu + (muma.bottom > window.innerHeight ? (window.innerHeight - pudu) / 2 : muma.height / 2)) ; muma && muma !== coufi && muma !== document;) {
if (muma.tagName && 'string' === typeof muma.tagName && 'label' === muma.tagName.toLowerCase() && coufi.labels && 0 < coufi.labels.length) {
return 0 <= Array.prototype.slice.call(coufi.labels).indexOf(muma);
}
muma = muma.parentNode;
}
return muma === coufi;
}
function jasu(sebe) {
var jutuem;
if (void 0 === sebe || null === sebe) {
return null;
}
try {
var paraf = Array.prototype.slice.call(getFormElements(document)), viehi = paraf.filter(function (strukou) {
return strukou.opid == sebe;
});
if (0 < viehi.length) {
jutuem = viehi[0], 1 < viehi.length && console.warn('More than one element found with opid ' + sebe);
} else {
var jotun = parseInt(sebe.split('__')[1], 10);
isNaN(jotun) || (jutuem = paraf[jotun]);
}
} catch (beynad) {
console.error('An unexpected error occurred: ' + beynad);
} finally {
return jutuem;
}
}
// get all the form elements that we care about
function getFormElements(theDoc) {
var els = [];
try {
els = theDoc.querySelectorAll('input, select, button');
} catch (e) { }
return els;
}
function jesceln(calo, noru) {
if (noru) {
var klebup = calo.value;
calo.focus();
calo.value !== klebup && (calo.value = klebup);
} else {
calo.focus();
}
}
return JSON.stringify(sasrie(document, 'oneshotUUID'));
}
function fill(document, fillScript, undefined) {
var isFirefox = navigator.userAgent.indexOf('Firefox') !== -1 || navigator.userAgent.indexOf('Gecko/') !== -1;
var g=!0,k=!0;
function n(a){var b=null;return a?0===a.indexOf('https://')&&'http:'===document.location.protocol&&(b=document.querySelectorAll('input[type=password]'),0<b.length&&(confirmResult=confirm('1Password warning: This is an unsecured HTTP page, and any information you submit can potentially be seen and changed by others. This Login was originally saved on a secure (HTTPS) page.\\n\\nDo you still wish to fill this login?'),0==confirmResult))?!0:!1:!1}
function m(a){var b,c=[],d=a.properties,e=1,h,f=[];d&&d.delay_between_operations&&(e=d.delay_between_operations);if(!n(a.savedURL)){h=function(a,b){var d=a[0];if(void 0===d)b();else{if('delay'===d.operation||'delay'===d[0])e=d.parameters?d.parameters[0]:d[1];else{if(d=p(d))for(var l=0;l<d.length;l++)-1===f.indexOf(d[l])&&f.push(d[l]);c=c.concat(f.map(function(a){return a&&a.hasOwnProperty('opid')?a.opid:null}))}setTimeout(function(){h(a.slice(1),b)},e)}};if(b=a.options)b.hasOwnProperty('animate')&&
(k=b.animate),b.hasOwnProperty('markFilling')&&(g=b.markFilling);a.itemType&&'fillPassword'===a.itemType&&(g=!1);a.hasOwnProperty('script')&&(b=a.script,h(b,function(){a.hasOwnProperty('autosubmit')&&'function'==typeof autosubmit&&(a.itemType&&'fillLogin'!==a.itemType||(0<f.length?setTimeout(function(){autosubmit(a.autosubmit,d.allow_clicky_autosubmit,f)},AUTOSUBMIT_DELAY):DEBUG_AUTOSUBMIT&&console.log('[AUTOSUBMIT] Not attempting to submit since no fields were filled: ',f)));'object'==typeof protectedGlobalPage&&
protectedGlobalPage.b('fillItemResults',{documentUUID:documentUUID,fillContextIdentifier:a.fillContextIdentifier,usedOpids:c},function(){fillingItemType=null})}))}}var x={fill_by_opid:q,fill_by_query:r,click_on_opid:s,click_on_query:t,touch_all_fields:u,simple_set_value_by_query:v,focus_by_opid:w,delay:null};
function p(a){var b;if(a.hasOwnProperty('operation')&&a.hasOwnProperty('parameters'))b=a.operation,a=a.parameters;else if('[object Array]'===Object.prototype.toString.call(a))b=a[0],a=a.splice(1);else return null;return x.hasOwnProperty(b)?x[b].apply(this,a):null}function q(a,b){var c;return(c=y(a))?(z(c,b),[c]):null}function r(a,b){var c;c=A(a);return Array.prototype.map.call(Array.prototype.slice.call(c),function(a){z(a,b);return a},this)}
function v(a,b){var c,d=[];c=A(a);Array.prototype.forEach.call(Array.prototype.slice.call(c),function(a){a.disabled||a.a||a.readOnly||void 0===a.value||(a.value=b,d.push(a))});return d}function w(a){if(a=y(a))'function'===typeof a.click&&a.click(),'function'===typeof a.focus&&B(a,!0);return null}function s(a){return(a=y(a))?C(a)?[a]:null:null}
function t(a){a=A(a);return Array.prototype.map.call(Array.prototype.slice.call(a),function(a){C(a);'function'===typeof a.click&&a.click();'function'===typeof a.focus&&B(a,!0);return[a]},this)}function u(){D()};var E={'true':!0,y:!0,1:!0,yes:!0,'✓':!0},F=200;function z(a,b){var c;if(a&&null!==b&&void 0!==b&&!(a.disabled||a.a||a.readOnly))switch(g&&a.form&&!a.form.opfilled&&(a.form.opfilled=!0),a.type?a.type.toLowerCase():null){case 'checkbox':c=b&&1<=b.length&&E.hasOwnProperty(b.toLowerCase())&&!0===E[b.toLowerCase()];a.checked===c||G(a,function(a){a.checked=c});break;case 'radio':!0===E[b.toLowerCase()]&&a.click();break;default:a.value==b||G(a,function(a){a.value=b})}}
function G(a,b){H(a);b(a);I(a);J(a)&&(a.className+=' com-agilebits-onepassword-extension-animated-fill',setTimeout(function(){a&&a.className&&(a.className=a.className.replace(/(\\s)?com-agilebits-onepassword-extension-animated-fill/,''))},F))};document.elementForOPID=y;function K(a,b){var c;isFirefox?(c=document.createEvent('KeyboardEvent'),c.initKeyEvent(b,!0,!1,null,!1,!1,!1,!1,0,0)):(c=a.ownerDocument.createEvent('Events'),c.initEvent(b,!0,!1),c.charCode=0,c.keyCode=0,c.which=0,c.srcElement=a,c.target=a);return c}function H(a){var b=a.value;C(a);B(a,!1);a.dispatchEvent(K(a,'keydown'));a.dispatchEvent(K(a,'keypress'));a.dispatchEvent(K(a,'keyup'));a.value!==b&&(a.value=b)}
function I(a){var b=a.value,c=a.ownerDocument.createEvent('HTMLEvents'),d=a.ownerDocument.createEvent('HTMLEvents');a.dispatchEvent(K(a,'keydown'));a.dispatchEvent(K(a,'keypress'));a.dispatchEvent(K(a,'keyup'));d.initEvent('input',!0,!0);a.dispatchEvent(d);c.initEvent('change',!0,!0);a.dispatchEvent(c);a.blur();a.value!==b&&(a.value=b)}function C(a){if(!a||a&&'function'!==typeof a.click)return!1;a.click();return!0}
function L(){var a=RegExp('((\\\\b|_|-)pin(\\\\b|_|-)|password|passwort|kennwort|passe|contraseña|senha|密码|adgangskode|hasło|wachtwoord)','i');return Array.prototype.slice.call(A("input[type='text']")).filter(function(b){return b.value&&a.test(b.value)},this)}function D(){L().forEach(function(a){H(a);a.click&&a.click();I(a)})}
window.LOGIN_TITLES=[/^\\W*log\\W*[oi]n\\W*$/i,/log\\W*[oi]n (?:securely|now)/i,/^\\W*sign\\W*[oi]n\\W*$/i,'continue','submit','weiter','accès','вход','connexion','entrar','anmelden','accedi','valider','登录','लॉग इन करें','change password'];window.LOGIN_RED_HERRING_TITLES=['already have an account','sign in with'];window.REGISTER_TITLES='register;sign up;signup;join;create my account;регистрация;inscription;regístrate;cadastre-se;registrieren;registrazione;注册;साइन अप करें'.split(';');
window.SEARCH_TITLES='search find поиск найти искать recherche suchen buscar suche ricerca procurar 検索'.split(' ');window.FORGOT_PASSWORD_TITLES='forgot geändert vergessen hilfe changeemail español'.split(' ');window.REMEMBER_ME_TITLES=['remember me','rememberme','keep me signed in'];window.BACK_TITLES=['back','назад'];
function J(a){var b;if(b=k)a:{b=a;for(var c=a.ownerDocument,c=c?c.defaultView:{},d;b&&b!==document;){d=c.getComputedStyle?c.getComputedStyle(b,null):b.style;if(!d){b=!0;break a}if('none'===d.display||'hidden'==d.visibility){b=!1;break a}b=b.parentNode}b=b===document}return b?-1!=='email text password number tel url'.split(' ').indexOf(a.type||''):!1}
function y(a){var b;if(void 0===a||null===a)return null;try{var c=Array.prototype.slice.call(A('input, select, button')),d=c.filter(function(b){return b.opid==a});if(0<d.length)b=d[0],1<d.length&&console.warn('More than one element found with opid '+a);else{var e=parseInt(a.split('__')[1],10);isNaN(e)||(b=c[e])}}catch(h){console.error('An unexpected error occurred: '+h)}finally{return b}};function A(a){var b=document,c=[];try{c=b.querySelectorAll(a)}catch(d){}return c}function B(a,b){if(b){var c=a.value;a.focus();a.value!==c&&(a.value=c)}else a.focus()};
m(fillScript);
return JSON.stringify({'success': true});
var markTheFilling = true,
animateTheFilling = true;
// Check if URL is not secure when the original saved one was
function urlNotSecure(savedURL) {
var passwordInputs = null;
if (!savedURL) {
return false;
}
return 0 === savedURL.indexOf('https://') && 'http:' === document.location.protocol && (passwordInputs = document.querySelectorAll('input[type=password]'),
0 < passwordInputs.length && (confirmResult = confirm('Warning: This is an unsecured HTTP page, and any information you submit can potentially be seen and changed by others. This Login was originally saved on a secure (HTTPS) page.\\n\\nDo you still wish to fill this login?'),
0 == confirmResult)) ? true : false;
}
function doFill(fillScript) {
var fillScriptOps,
theOpIds = [],
fillScriptProperties = fillScript.properties,
operationDelayMs = 1,
doOperation,
operationsToDo = [];
fillScriptProperties &&
fillScriptProperties.delay_between_operations &&
(operationDelayMs = fillScriptProperties.delay_between_operations);
if (urlNotSecure(fillScript.savedURL)) {
return;
}
doOperation = function (ops, theOperation) {
var op = ops[0];
if (void 0 === op) {
theOperation();
} else {
// should we delay?
if ('delay' === op.operation || 'delay' === op[0]) {
operationDelayMs = op.parameters ? op.parameters[0] : op[1];
} else {
if (op = normalizeOp(op)) {
for (var opIndex = 0; opIndex < op.length; opIndex++) {
-1 === operationsToDo.indexOf(op[opIndex]) && operationsToDo.push(op[opIndex]);
}
}
theOpIds = theOpIds.concat(operationsToDo.map(function (operationToDo) {
return operationToDo && operationToDo.hasOwnProperty('opid') ? operationToDo.opid : null;
}));
}
setTimeout(function () {
doOperation(ops.slice(1), theOperation);
}, operationDelayMs);
}
};
if (fillScriptOps = fillScript.options) {
fillScriptOps.hasOwnProperty('animate') && (animateTheFilling = fillScriptOps.animate),
fillScriptOps.hasOwnProperty('markFilling') && (markTheFilling = fillScriptOps.markFilling);
}
// don't mark a password filling
fillScript.itemType && 'fillPassword' === fillScript.itemType && (markTheFilling = false);
if (!fillScript.hasOwnProperty('script')) {
return;
}
// custom fill script
fillScriptOps = fillScript.script;
doOperation(fillScriptOps, function () {
// Done now
// Do we have anything to autosubmit?
if (fillScript.hasOwnProperty('autosubmit') && 'function' == typeof autosubmit) {
fillScript.itemType && 'fillLogin' !== fillScript.itemType || (0 < operationsToDo.length ? setTimeout(function () {
autosubmit(fillScript.autosubmit, fillScriptProperties.allow_clicky_autosubmit, operationsToDo);
}, AUTOSUBMIT_DELAY) : DEBUG_AUTOSUBMIT && console.log('[AUTOSUBMIT] Not attempting to submit since no fields were filled: ', operationsToDo))
}
// handle protectedGlobalPage
if ('object' == typeof protectedGlobalPage) {
protectedGlobalPage.b('fillItemResults', {
documentUUID: documentUUID,
fillContextIdentifier: fillScript.fillContextIdentifier,
usedOpids: theOpIds
}, function () {
fillingItemType = null;
})
}
});
}
// fill for reference
var thisFill = {
fill_by_opid: doFillByOpId,
fill_by_query: doFillByQuery,
click_on_opid: doClickByOpId,
click_on_query: doClickByQuery,
touch_all_fields: touchAllFields,
simple_set_value_by_query: doSimpleSetByQuery,
focus_by_opid: doFocusByOpId,
delay: null
};
// normalize the op versus the reference
function normalizeOp(op) {
var thisOperation;
if (op.hasOwnProperty('operation') && op.hasOwnProperty('parameters')) {
thisOperation = op.operation, op = op.parameters;
} else {
if ('[object Array]' === Object.prototype.toString.call(op)) {
thisOperation = op[0],
op = op.splice(1);
} else {
return null;
}
}
return thisFill.hasOwnProperty(thisOperation) ? thisFill[thisOperation].apply(this, op) : null;
}
// do a fill by opid operation
function doFillByOpId(opId, op) {
var el = getElementByOpId(opId);
return el ? (fillTheElement(el, op), [el]) : null;
}
// do a fill by query operation
function doFillByQuery(query, op) {
var elements = selectAllFromDoc(query);
return Array.prototype.map.call(Array.prototype.slice.call(elements), function (el) {
fillTheElement(el, op);
return el;
}, this);
}
// do a simple set value by query
function doSimpleSetByQuery(query, valueToSet) {
var elements = selectAllFromDoc(query),
arr = [];
Array.prototype.forEach.call(Array.prototype.slice.call(elements), function (el) {
el.disabled || el.a || el.readOnly || void 0 === el.value || (el.value = valueToSet, arr.push(el));
});
return arr;
}
// focus by opid
function doFocusByOpId(opId) {
var el = getElementByOpId(opId)
if (el) {
'function' === typeof el.click && el.click(),
'function' === typeof el.focus && doFocusElement(el, true);
}
return null;
}
// do a click by opid operation
function doClickByOpId(opId) {
var el = getElementByOpId(opId);
return el ? clickElement(el) ? [el] : null : null;
}
// do a click by query operation
function doClickByQuery(query) {
query = selectAllFromDoc(query);
return Array.prototype.map.call(Array.prototype.slice.call(query), function (el) {
clickElement(el);
'function' === typeof el.click && el.click();
'function' === typeof el.focus && doFocusElement(el, true);
return [el];
}, this);
}
var checkRadioTrueOps = {
'true': true,
y: true,
1: true,
yes: true,
'✓': true
},
styleTimeout = 200;
// fill an element
function fillTheElement(el, op) {
var shouldCheck;
if (el && null !== op && void 0 !== op && !(el.disabled || el.a || el.readOnly)) {
switch (markTheFilling && el.form && !el.form.opfilled && (el.form.opfilled = true),
el.type ? el.type.toLowerCase() : null) {
case 'checkbox':
shouldCheck = op && 1 <= op.length && checkRadioTrueOps.hasOwnProperty(op.toLowerCase()) && true === checkRadioTrueOps[op.toLowerCase()];
el.checked === shouldCheck || doAllFillOperations(el, function (theEl) {
theEl.checked = shouldCheck;
});
break;
case 'radio':
true === checkRadioTrueOps[op.toLowerCase()] && el.click();
break;
default:
el.value == op || doAllFillOperations(el, function (theEl) {
theEl.value = op;
});
}
}
}
// do all the full operations needed
function doAllFillOperations(el, afterValSetFunc) {
setValueForElement(el);
afterValSetFunc(el);
setValueForElementByEvent(el);
canSeeElementToStyle(el) && (el.className += ' com-agilebits-onepassword-extension-animated-fill',
setTimeout(function () {
el && el.className && (el.className = el.className.replace(/(\\s)?com-agilebits-onepassword-extension-animated-fill/, ''));
}, styleTimeout));
}
document.elementForOPID = getElementByOpId;
// normalize the event since firefox handles events differently than others
function normalizeEvent(el, eventName) {
var ev;
if (isFirefox) {
ev = document.createEvent('KeyboardEvent');
ev.initKeyEvent(eventName, true, false, null, false, false, false, false, 0, 0);
}
else {
ev = el.ownerDocument.createEvent('Events');
ev.initEvent(eventName, true, false);
ev.charCode = 0;
ev.keyCode = 0;
ev.which = 0;
ev.srcElement = el;
ev.target = el;
}
return ev;
}
// set value of the given element
function setValueForElement(el) {
var valueToSet = el.value;
clickElement(el);
doFocusElement(el, false);
el.dispatchEvent(normalizeEvent(el, 'keydown'));
el.dispatchEvent(normalizeEvent(el, 'keypress'));
el.dispatchEvent(normalizeEvent(el, 'keyup'));
el.value !== valueToSet && (el.value = valueToSet);
}
// set value of the given element by using events
function setValueForElementByEvent(el) {
var valueToSet = el.value,
ev1 = el.ownerDocument.createEvent('HTMLEvents'),
ev2 = el.ownerDocument.createEvent('HTMLEvents');
el.dispatchEvent(normalizeEvent(el, 'keydown'));
el.dispatchEvent(normalizeEvent(el, 'keypress'));
el.dispatchEvent(normalizeEvent(el, 'keyup'));
ev2.initEvent('input', true, true);
el.dispatchEvent(ev2);
ev1.initEvent('change', true, true);
el.dispatchEvent(ev1);
el.blur();
el.value !== valueToSet && (el.value = valueToSet);
}
// click on an element
function clickElement(el) {
if (!el || el && 'function' !== typeof el.click) {
return false;
}
el.click();
return true;
}
// get all fields we care about
function getAllFields() {
var r = RegExp('((\\\\b|_|-)pin(\\\\b|_|-)|password|passwort|kennwort|passe|contraseña|senha|密码|adgangskode|hasło|wachtwoord)', 'i');
return Array.prototype.slice.call(selectAllFromDoc("input[type='text']")).filter(function (el) {
return el.value && r.test(el.value);
}, this);
}
// touch all the fields
function touchAllFields() {
getAllFields().forEach(function (el) {
setValueForElement(el);
el.click && el.click();
setValueForElementByEvent(el);
});
}
// some useful globals
window.LOGIN_TITLES = [/^\\W*log\\W*[oi]n\\W*$/i, /log\\W*[oi]n (?:securely|now)/i, /^\\W*sign\\W*[oi]n\\W*$/i, 'continue', 'submit', 'weiter', 'accès', 'вход', 'connexion', 'entrar', 'anmelden', 'accedi', 'valider', '登录', 'लॉग इन करें', 'change password'];
window.LOGIN_RED_HERRING_TITLES = ['already have an account', 'sign in with'];
window.REGISTER_TITLES = 'register;sign up;signup;join;create my account;регистрация;inscription;regístrate;cadastre-se;registrieren;registrazione;注册;साइन अप करें'.split(';');
window.SEARCH_TITLES = 'search find поиск найти искать recherche suchen buscar suche ricerca procurar 検索'.split(' ');
window.FORGOT_PASSWORD_TITLES = 'forgot geändert vergessen hilfe changeemail español'.split(' ');
window.REMEMBER_ME_TITLES = ['remember me', 'rememberme', 'keep me signed in'];
window.BACK_TITLES = ['back', 'назад'];
// can we see the element to apply some styling?
function canSeeElementToStyle(el) {
var currentEl;
if (currentEl = animateTheFilling) {
a: {
currentEl = el;
for (var owner = el.ownerDocument, owner = owner ? owner.defaultView : {}, theStyle; currentEl && currentEl !== document;) {
theStyle = owner.getComputedStyle ? owner.getComputedStyle(currentEl, null) : currentEl.style;
if (!theStyle) {
currentEl = true;
break a;
}
if ('none' === theStyle.display || 'hidden' == theStyle.visibility) {
currentEl = false;
break a;
}
currentEl = currentEl.parentNode;
}
currentEl = currentEl === document;
}
}
return currentEl ? -1 !== 'email text password number tel url'.split(' ').indexOf(el.type || '') : false;
}
// find the element for this operation
function getElementByOpId(theOpId) {
var theElement;
if (void 0 === theOpId || null === theOpId) {
return null;
}
try {
var elements = Array.prototype.slice.call(selectAllFromDoc('input, select, button'));
var filteredElements = elements.filter(function (o) {
return o.opid == theOpId;
});
if (0 < filteredElements.length) {
theElement = filteredElements[0],
1 < filteredElements.length && console.warn('More than one element found with opid ' + theOpId);
} else {
var elIndex = parseInt(theOpId.split('__')[1], 10);
isNaN(elIndex) || (theElement = elements[elIndex]);
}
} catch (e) {
console.error('An unexpected error occurred: ' + e);
} finally {
return theElement;
}
}
// helper for doc.querySelectorAll
function selectAllFromDoc(theSelector) {
var d = document, elements = [];
try {
elements = d.querySelectorAll(theSelector);
} catch (e) { }
return elements;
}
// focus an element and optionally re-set its value after focusing
function doFocusElement(el, setValue) {
if (setValue) {
var existingValue = el.value;
el.focus();
el.value !== existingValue && (el.value = existingValue);
} else {
el.focus();
}
}
doFill(fillScript);
return JSON.stringify({
success: true
});
}
/*