📜 ⬆️ ⬇️

Russian passwords in Safari / Mac OS X

Today I ran into such a problem: you need to enter a password containing Russian characters. But it was not there. Safari just refused to switch language! A simple solution would be to enter the password in TextEdit and copy it into the password field, but the body required a more elegant solution to the problem. And so, remembering the techniques of CSS-jitsu and Javascript-fu, overcoming the Friday desire to go get drunk or go through Braid at last, your humble servant rushed into battle ...


The solution was surprisingly simple, but the path to it was quite long. The first and most obvious step was to replace all fields with a password type with fields with a text type. But how can a user-entered text be hidden back? The first test solution was to make the text transparent: color: rgba(0,0,0,0) . But in this case, the user simply did not see how many characters he entered, and whether the field is empty. In short, after a long search on Surfin 'Safari, I came across a wonderful CSS property: -webkit-text-security ! This property causes any Safari starting from version 3 to show disks ( -webkit-text-security: disk ), circles ( -webkit-text-security: circle ) or squares ( -webkit-text-security: square ) -webkit-text-security: square . As a result, we have the following javascript function:

 function() { var F = document.forms; for(var j=0; j<F.length; ++j) { var f = F[j]; for (var i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") { var el = f[i]; el.type = "text"; el.style.cssText = "-webkit-text-security: disc"; } } } } 

')
But the bookmark, which should be dragged into the bookmarks bar and used, I (for obvious reasons) can not place here. Therefore, I will give only his code:

javascript:(function(){var F=document.forms;for(var j=0;j<F.length;++j){var f=F[j];for(var i=0;i<f.length;++i){if(f[i].type.toLowerCase()=="password"){var el=f[i];el.type="text";el.style.cssText="-webkit-text-security:disc";}}}})();

Use on health. ;-)

ps If someone knows how to eradicate this problem dramatically, I will be glad to hear and demolish this post nafig. Apparently the root of the problem is hidden in the bowels of the OS itself, since All password fields in Mac OS X behave in a similar way (I have 10.5.7).

Source: https://habr.com/ru/post/64756/


All Articles