3

Hopefully someone can help me here. I use a login page everyday given by my ISP to login and start internet on my machine. In between the connection goes off a couple of times and I am redirected to the login page. On clicking the Login button, the internet starts again.

My question. Can I automatically detect if the internet is off and use a script that auto logs me in.

THe Login button on the redirected page looks like this

<input type="submit" name="Submit" id="btnSubmit" value="Login" onclick="return checking();" />
Ref
  • 33
  • 1
  • 3
  • Ideally a Linux/BASH solution as well. – Christian Mann Nov 07 '10 at 04:57
  • I am on a windows box. so a Linux soln wont work – Ref Nov 07 '10 at 05:00
  • possible duplicate of [JavaScript: How to detect that the Internet connection is offline?](http://stackoverflow.com/questions/189430/javascript-how-to-detect-that-the-internet-connection-is-offline) – meder omuraliev Nov 07 '10 at 05:03
  • 2
    meder: no its not a duplicate if you read my question again – Ref Nov 07 '10 at 05:20
  • Did you read the answer there pointing to IEs **navigator.onLine** ? This should be a solution, you can use it for example inside a skript hosted by WSH, that runs in the background. – Dr.Molle Nov 07 '10 at 06:59

1 Answers1

1

The real problem may be in a DSL modem and/or setup. For example, I've seen this a lot with people using 2Wire brand modems.

But the general task is a common one.   The following is a generic Greasemonkey script that will work -- but you will have to tweak it slightly because enough of the login page was not provided.

Ideally, save the entire login page, strip out any IP addresses or passwords and then paste it here or at Pastebin.com. Then we can give a more exact solution.

Script:

// ==UserScript==
// @name            Generic Auto Relogin
// @namespace       GenericLocal
// @description     Just removes a login annoyance.  WARNING:  This compromises security!
// @include         *
// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==


$(document).ready(Greasemonkey_main);


/*--- WARNING!  Username and password!!!
*/
var sGbl_Username       = 'For demonstration purposes only!';
var sGbl_Password       = 'Hopefully you know that this is a bad idea';


function Greasemonkey_main ()
{
    //--- Is this a login screen? ---
    var zLoginForm      = $("input#btnSubmit");
    if (zLoginForm  &&  zLoginForm.length)
    {
        //--- Set username and password. ---
        $("input#username").attr ('value', sGbl_Username);
        $("input#password").attr ('value', sGbl_Password);

        //--- Submit the login form.
        $("input#btnSubmit")[0].click (); //-- Click submit button.
}
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • Many thanks! How can I access username pwd in greasemonkey and set it as you showed, using plain javascript? – Ref Nov 07 '10 at 10:14
  • The username field has two entries like this – Ref Nov 07 '10 at 10:59
  • I don't understand the 1st question; the answer shows how to set username and password. Did you want to use a bookmarklet instead? (An even bigger security risk) Please elaborate. – Brock Adams Nov 07 '10 at 19:07
  • Re: "The username field has two entries like"... Sorry but that is not good enough. In order to avoid false triggers, and to ensure the correct form fields are filled out, **exact details** are needed. What are the `id`s of the elements? Their embedded structure? Please paste the exact source HTML of the login page (editing IP's and passwords *only*). – Brock Adams Nov 07 '10 at 19:13