WebBrowser/Tools/Scripts.py

changeset 5747
fcc83c509ce9
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5745:4f4316e83318 5747:fcc83c509ce9
243 @rtype str 243 @rtype str
244 """ 244 """
245 source = """ 245 source = """
246 (function() { 246 (function() {
247 function findUsername(inputs) { 247 function findUsername(inputs) {
248 for (var i = 0; i < inputs.length; ++i) 248 var usernameNames = ['user', 'name', 'login'];
249 if (inputs[i].type == 'text' && inputs[i].value.length && 249 for (var i = 0; i < usernameNames.length; ++i) {
250 inputs[i].name.indexOf('user') != -1) 250 for (var j = 0; j < inputs.length; ++j)
251 return inputs[i].value; 251 if (inputs[j].type == 'text' &&
252 for (var i = 0; i < inputs.length; ++i) 252 inputs[j].value.length &&
253 if (inputs[i].type == 'text' && inputs[i].value.length && 253 inputs[j].name.indexOf(usernameNames[i]) != -1)
254 inputs[i].name.indexOf('name') != -1) 254 return inputs[j].value;
255 return inputs[i].value; 255 }
256 for (var i = 0; i < inputs.length; ++i) 256 for (var i = 0; i < inputs.length; ++i)
257 if (inputs[i].type == 'text' && inputs[i].value.length) 257 if (inputs[i].type == 'text' && inputs[i].value.length)
258 return inputs[i].value; 258 return inputs[i].value;
259 for (var i = 0; i < inputs.length; ++i) 259 for (var i = 0; i < inputs.length; ++i)
260 if (inputs[i].type == 'email' && inputs[i].value.length) 260 if (inputs[i].type == 'email' && inputs[i].value.length)
295 registerForm(document.forms[i]); 295 registerForm(document.forms[i]);
296 296
297 var observer = new MutationObserver(function(mutations) { 297 var observer = new MutationObserver(function(mutations) {
298 for (var i = 0; i < mutations.length; ++i) 298 for (var i = 0; i < mutations.length; ++i)
299 for (var j = 0; j < mutations[i].addedNodes.length; ++j) 299 for (var j = 0; j < mutations[i].addedNodes.length; ++j)
300 if (mutations[i].addedNodes[j].tagName == 'form') 300 if (mutations[i].addedNodes[j].tagName == 'FORM')
301 registerForm(mutations[i].addedNodes[j]); 301 registerForm(mutations[i].addedNodes[j]);
302 }); 302 });
303 observer.observe(document.documentElement, { childList: true }); 303 observer.observe(document.documentElement, {
304 childList: true, subtree: true
305 });
304 306
305 })()""" 307 })()"""
306 return source 308 return source
307 309
308 310

eric ide

mercurial