Skip to content

Instantly share code, notes, and snippets.

@glukki
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save glukki/d9d61709dc9c1f4354d8 to your computer and use it in GitHub Desktop.

Select an option

Save glukki/d9d61709dc9c1f4354d8 to your computer and use it in GitHub Desktop.

Revisions

  1. glukki revised this gist Aug 2, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ var Logic = function(options){

    Logic.prototype.CHECK_URL = "http://www.apple.com/library/test/success.html";
    Logic.prototype.SUCCESS = "Success";
    Logic.prototype.INTERVAL = 30 * 1000; // 1 minute
    Logic.prototype.INTERVAL = 30 * 1000; // 30 seconds

    Logic.prototype.reload = function() {
    this._window.location = this.CHECK_URL;
  2. glukki revised this gist Aug 2, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    // @name Free WiFi Reconnect
    // @namespace http://glukki.ru/
    // @description Detects free Wi-Fi timelimit expiration and logs you back in
    // @version 0.0.4
    // @version 0.0.5
    // @updateURL https://gist.githubusercontent.com/glukki/d9d61709dc9c1f4354d8/raw/FreeWifiReconnect.js
    // @match http://www.apple.com/library/test/success.html
    // @match *://login.connectum.ru/*
    @@ -54,7 +54,7 @@ Logic.prototype.connect = function() {
    if (type === "#") {
    element = this._window.document.getElementById(strategy);
    } else if (type === ".") {
    element = this._window.document.getElementByClassName(strategy)[0]
    element = this._window.document.getElementsByClassName(strategy)[0]
    } else {
    return alert("Selector not supported");
    }
  3. glukki revised this gist Aug 2, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    // @name Free WiFi Reconnect
    // @namespace http://glukki.ru/
    // @description Detects free Wi-Fi timelimit expiration and logs you back in
    // @version 0.0.3
    // @version 0.0.4
    // @updateURL https://gist.githubusercontent.com/glukki/d9d61709dc9c1f4354d8/raw/FreeWifiReconnect.js
    // @match http://www.apple.com/library/test/success.html
    // @match *://login.connectum.ru/*
    @@ -51,9 +51,9 @@ Logic.prototype.connect = function() {
    var element;
    var type = strategy[0];
    strategy = strategy.substr(1);
    if (type === ".") {
    if (type === "#") {
    element = this._window.document.getElementById(strategy);
    } else if (type === "#") {
    } else if (type === ".") {
    element = this._window.document.getElementByClassName(strategy)[0]
    } else {
    return alert("Selector not supported");
  4. glukki revised this gist Aug 2, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,10 @@
    // @name Free WiFi Reconnect
    // @namespace http://glukki.ru/
    // @description Detects free Wi-Fi timelimit expiration and logs you back in
    // @version 0.0.2
    // @version 0.0.3
    // @updateURL https://gist.githubusercontent.com/glukki/d9d61709dc9c1f4354d8/raw/FreeWifiReconnect.js
    // @match http://www.apple.com/library/test/success.html
    // @match http://login.connectum.ru
    // @match *://login.connectum.ru/*
    // @grant unsafeWindow
    // @copyright 2014+, Vitaliy Meschaninov
    // ==/UserScript==
  5. glukki revised this gist Aug 2, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    // @name Free WiFi Reconnect
    // @namespace http://glukki.ru/
    // @description Detects free Wi-Fi timelimit expiration and logs you back in
    // @version 0.0.1
    // @version 0.0.2
    // @updateURL https://gist.githubusercontent.com/glukki/d9d61709dc9c1f4354d8/raw/FreeWifiReconnect.js
    // @match http://www.apple.com/library/test/success.html
    // @match http://login.connectum.ru
    @@ -16,7 +16,7 @@ var Logic = function(options){

    Logic.prototype.CHECK_URL = "http://www.apple.com/library/test/success.html";
    Logic.prototype.SUCCESS = "Success";
    LOGIC.prototype.INTERVAL = 30 * 1000; // 1 minute
    Logic.prototype.INTERVAL = 30 * 1000; // 1 minute

    Logic.prototype.reload = function() {
    this._window.location = this.CHECK_URL;
  6. glukki revised this gist Aug 2, 2014. 1 changed file with 11 additions and 2 deletions.
    13 changes: 11 additions & 2 deletions FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ var Logic = function(options){

    Logic.prototype.CHECK_URL = "http://www.apple.com/library/test/success.html";
    Logic.prototype.SUCCESS = "Success";
    LOGIC.prototype.INTERVAL = 1 * 60 * 1000; // 1 minute
    LOGIC.prototype.INTERVAL = 30 * 1000; // 1 minute

    Logic.prototype.reload = function() {
    this._window.location = this.CHECK_URL;
    @@ -82,4 +82,13 @@ Logic.prototype.run = function() {
    */
    Logic.prototype.strategy = {
    "login.connectum.ru": ".connectbutton"
    };
    };



    (function() {
    var instance = new Logic({
    window: unsafeWindow
    });
    instance.run();
    })();
  7. glukki revised this gist Aug 2, 2014. 1 changed file with 85 additions and 1 deletion.
    86 changes: 85 additions & 1 deletion FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -1 +1,85 @@
    //
    // ==UserScript==
    // @name Free WiFi Reconnect
    // @namespace http://glukki.ru/
    // @description Detects free Wi-Fi timelimit expiration and logs you back in
    // @version 0.0.1
    // @updateURL https://gist.githubusercontent.com/glukki/d9d61709dc9c1f4354d8/raw/FreeWifiReconnect.js
    // @match http://www.apple.com/library/test/success.html
    // @match http://login.connectum.ru
    // @grant unsafeWindow
    // @copyright 2014+, Vitaliy Meschaninov
    // ==/UserScript==

    var Logic = function(options){
    this._window = options.window;
    };

    Logic.prototype.CHECK_URL = "http://www.apple.com/library/test/success.html";
    Logic.prototype.SUCCESS = "Success";
    LOGIC.prototype.INTERVAL = 1 * 60 * 1000; // 1 minute

    Logic.prototype.reload = function() {
    this._window.location = this.CHECK_URL;
    };

    Logic.prototype.checkSuccess = function() {
    if (this._window && this._window.document && this._window.document.title === this.SUCCESS) {
    return true;
    }
    return false;
    };

    Logic.prototype.connect = function() {
    var strategy = this.strategy[this._window.location.hostname];
    if (!strategy) {
    return alert("We have no strategy for this network");
    }

    if (typeof strategy === "object") {
    var keys = Object.keys(strategy);
    for (var i = 0; i < keys.length; i += 1) {
    if (this._window.location.pathname.indexOf(strategy[keys[i]]) !== -1){
    strategy = strategy[keys[i]];
    break;
    }
    }
    if(typeof strategy !== "string") {
    return alert("We have no matching strategy for this network");
    }
    }

    var element;
    var type = strategy[0];
    strategy = strategy.substr(1);
    if (type === ".") {
    element = this._window.document.getElementById(strategy);
    } else if (type === "#") {
    element = this._window.document.getElementByClassName(strategy)[0]
    } else {
    return alert("Selector not supported");
    }

    if (!element) {
    return alert("Cant get required element");
    }

    element.click();
    };

    Logic.prototype.run = function() {
    if (!this.checkSuccess()) {
    return this.connect();
    }

    setTimeout(this.reload.bind(this), this.INTERVAL);
    };

    /**
    * Click rules
    * hostname : selector
    * OR
    * hostname : pathname (substring) : selector
    */
    Logic.prototype.strategy = {
    "login.connectum.ru": ".connectbutton"
    };
  8. glukki created this gist Aug 2, 2014.
    1 change: 1 addition & 0 deletions FreeWifiReconnect.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    //