Permalink
Browse files

Wait 4s and get mini-digits.

  • Loading branch information...
1 parent 7e38439 commit f82aed305abdd6b2ec53a9ac6c2cca00ecd8d450 @g2p committed Mar 5, 2012
Showing with 32 additions and 4 deletions.
  1. +32 −4 authfreemobile.user.js
View
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Free Mobile: authentification classique
-// @version 0.0.39
+// @version 0.0.40
// @namespace https://github.com/g2p
// @author Gabriel <g2p.code@gmail.com> https://github.com/g2p
// @description Authentification Free Mobile sans clavier visuel
@@ -20,6 +20,8 @@ if ($('#ident_pos').length == 0)
let log = console.log;
+let FORM_DELAY_MILLIS = 4000;
+
let imgs = $('.pointer');
let img0 = imgs[0];
let width = img0.width;
@@ -178,15 +180,41 @@ function fixForm() {
$('p:first, #ident_txt_identifiant, #btAideVocale, .ident_chiffre2', form).hide();
$('<input type="text">')
.attr({id: 'ident_login'}).insertAfter('#ident_pos');
- $(form).submit(function() {
+ $(form).one('submit', function() {
let rdigits = ocr().rdigits;
let lgn = $('#ident_login').val();
let encoded = '';
+ let waiting = lgn.length;
+ let waitingTime = true;
+ let reqImgs = {};
+
+ $('<span class="red">').text(
+ 'En attente de soumission…').insertAfter('.ident_chiffre2');
+
+ setTimeout(function () {
+ waitingTime = false;
+ if (! waiting)
+ form.submit();
+ }, FORM_DELAY_MILLIS);
+
$.each(lgn, function(idx, digit) {
- encoded += rdigits[digit];
+ edigit = rdigits[digit];
+ encoded += edigit;
+
+ if (reqImgs[edigit]) {
+ waiting--;
+ return;
+ }
+
+ reqImgs[edigit] = true;
+ $.ajax('chiffre.php?pos=' + digit + '&small=1').always(function() {
+ waiting--;
+ if (! waiting && ! waitingTime)
+ form.submit();
+ });
});
$('#ident_pos').val(encoded);
- return true;
+ return false;
});
}

0 comments on commit f82aed3

Please sign in to comment.