glsjay / whv

// ==UserScript==
// @name        whv
// @description Try login and apply for the NZ whv for china
// @author      Jay Gong
// @include     https://www.immigration.govt.nz/
// @include     https://www.immigration.govt.nz/secure/Login+Working+Holiday.htm
// @include     http://www.immigration.govt.nz/migrant/default.htm
// @include		https://www.immigration.govt.nz/WorkingHoliday/
// @version     1.0
// @namespace   https://openuserjs.org/users/glsjay
// @require     http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
// @require     https://code.createjs.com/soundjs-0.6.1.min.js
// ==/UserScript==

//alert("Hello! bao bao is the cutest !!");
//window.location.replace("https://www.immigration.govt.nz/secure/Login+Working+Holiday.htm");
var username = "", 
	password = "",
    player;

player = document.createElement('audio');
player.src = 'http://static1.grsites.com/archive/sounds/bells/bells003.wav';
player.preload = 'auto';

$().ready(function() {
    var hostName = window.location.hostname,
    	url = window.location.href;
    
//  $("#ctl00_ContentPlaceHolder1_falseStatementCheckBox").attr('checked', false);
//	alert(hostName);
    
    if (url == "https://www.immigration.govt.nz/secure/Login+Working+Holiday.htm") {
        player.play();
        $("#OnlineServicesLoginStealth_VisaLoginControl_userNameTextBox").val(username);
        $("#OnlineServicesLoginStealth_VisaLoginControl_passwordTextBox").val(password);
        $("#OnlineServicesLoginStealth_VisaLoginControl_loginImageButton").click();
    	
    }else if (url == "http://www.immigration.govt.nz/migrant/default.htm") {
    	$("#OnlineServices_workingHolidayAnchor").click();

    }else if (url == "https://www.immigration.govt.nz/WorkingHoliday/") {
    	
    	$("#ctl00_ContentPlaceHolder1_countryDropDownList").val("46");
		$("#ctl00_ContentPlaceHolder1_okButton").click();
		
    }else if(url == "https://www.immigration.govt.nz/" || url == "https://www.immigration.govt.nz/error.htm?aspxerrorpath=/Templates/Custom/MasterHomepage.aspx"){
        
    	window.location.replace("https://www.immigration.govt.nz/secure/Login+Working+Holiday.htm");
    }
});