Skip to content

Instantly share code, notes, and snippets.

@scalopus
Created August 9, 2012 08:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scalopus/3302360 to your computer and use it in GitHub Desktop.
Save scalopus/3302360 to your computer and use it in GitHub Desktop.
True Wifi - Autologin script
// ==UserScript==
// @name Truewifi Auto Login/Logout 2
// @version 1.01
// @author Warun Kietduriyakul, script derived from Mr.Montree Phomkam
// @namespace http://www.jomyut.net
// @description True Wifi automatic login/re-login script when time is exceed.
// @include http*://portal.trueinternet.co.th/*
// ==/UserScript==
//################################################################
// Configuration Area
//################################################################
// User@Domain เช่น myusername@truehisp
// โดเมนที่มีได้แก่ truewifi,truemove,trueadsl,truehisp,wificard,kscbroadband,kscbroadbandlite,kscothers,ksconecard,kschotspot,au.edu,play,playnw,trueinternet,hispeednet,truefxip,playud
var login="username@truehisp";
// พาสเวิร์ด
var password="password";
// ระยะเวลาที่จะ Automatic Sign-in ใหม่อีกครั้ง (Truehisp ต้องน้อยกว่า 90 Minutes. [default:85] )
var minute = 85;
//################################################################
// ข้างล่างเป็นส่วนของสคริปต์การทำงาน ไม่ต้องแก้ไขอะไร
//################################################################
var index = 0;
var userdomain = login.split("@",2);
var domain = new Array();
domain['truewifi'] = index++;
domain['truemove'] = index++;
domain['trueadsl'] = index++;
domain['truehisp'] = index++;
domain['wificard'] = index++;
domain['kscbroadband'] = index++;
domain['kscbroadbandlite'] = index++;
domain['kscothers'] = index++;
domain['ksconecard'] = index++;
domain['kschotspot'] = index++;
domain['au.edu'] = index++;
domain['play'] = index++;
domain['playnw'] = index++;
domain['trueinternet'] = index++;
domain['hispeednet'] = index++;
domain['truefxip'] = index++;
domain['playud'] = index++;
var user = userdomain[0];
var domainIndex = domain[userdomain[1].toLowerCase()];
var macaddress = "00:1B:66:0C:0C:01";
var vlan = "851";
// url
var redirect = "http://portal.trueinternet.co.th/wifiauthen/login.do?VLAN=" + vlan + "&" + macaddress + "&VERSION=V2";
var showlogin = "https://portal.trueinternet.co.th/wifiauthen/login.php";
var logon = "https://portal.trueinternet.co.th/wifiauthen/login_result.php";
var logout = "https://portal.trueinternet.co.th/wifiauthen/logout_result.php";
// timer
var onesec = 1000; //set timeout 1 second
var tosec = minute * 60 * onesec; // automatic re-login in time.
// function countdown 90 minutes
window.setTimeout(
function()
{
if (document.location.href == logon) {
document.location = logout;
}
},
tosec
);
// funtcion redirect to showlogin page
window.setTimeout(
function()
{
if (document.location.href == logout){
document.location = redirect;
}
},
onesec
);
// function summit form
if (document.location.href == showlogin){
window.setTimeout(
function(){
for (var f = 0; f < document.forms.length; f++) {
if(document.forms[f].name=="form"){
dev = document.forms[f];
for (var e = 0; e < dev.elements.length; e++){
elm = dev.elements[e];
if(elm.name=="textuname"){
elm.value=user;
}else if(elm.name=="password"){
elm.value=password;
}else if(elm.name=="domain"){
elm.selectedIndex=domainIndex;
}else if(elm.name=="UserName"){
elm.value=user+'@'+password;
}
}
dev.action = logon;
dev.submit();
}
}
},
onesec
);
}
@yehtetlwin
Copy link

:-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment