User script: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
No edit summary
m (Reverted edits by Prashanthramesh (Talk) to last revision by Arantius)
Line 1: Line 1:
// ==UserScript==
{{stub}}
// @name        Satyam
// @namespace    http://thecinema.in/
// @description  script to play sound if ticket is available
// @include      http://thecinema.in/*
// @resource      GMwavaudio http://www.sensongs.com/UNDG/Tamil/Va%20Quarter%20Cutting  /09%20The%20Quarter%20Song%20Club%20Mix%20Remix%20Dj%20Vijay%20Chawla.mp3
// ==/UserScript==


var oggB64 = GM_getResourceURL("GMwavaudio");
'''User scripts''', or '''userscripts''', are scripts that make on-the-fly changes to specific web pages on the client side (in the browser or a proxy server), typically to change their appearance or to add or modify functionality.
var au = document.createElement('audio');
var ausrc = 'data:audio/wav;base64,'+oggB64.split('data:application/octet-stream;base64,')[1];
au.setAttribute('src', ausrc);
au.setAttribute('id', 'GMwavaudio');
document.body.appendChild(au);


var intval='';
User scripts for [[Greasemonkey]] and Greasemonkey-compatible alternatives are written in [http://developer.mozilla.org/en/docs/JavaScript JavaScript], but there is at least one example of using another scripting language, namely Ruby in [http://github.com/why/mousehole/tree/master/ MouseHole].
console.log('scriptloaded1');
intval=setInterval(function()
{
var http = new XMLHttpRequest();
var url = '/webWCF/AjaxBackService.svc/GetTicketDetail';
var params = '{"movieID":"ST00001292","date":"Friday |10 september"}';


http.open("POST", url, true);
For tools other than Greasemonkey that apply user scripts to web sites, see [[Cross-browser userscripting|Cross-browser Userscripting]] and [[wikipedia:Greasemonkey#Compatibility|Greasmonkey's compatibility]].


//Send the proper header information along with the request
== See Also ==
http.setRequestHeader("Content-type", "application/json");
* [[wikipedia:Augmented browsing|Augmented browsing at Wikipedia]]
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
 
http.onreadystatechange = function() {//Call a function when the state changes.
                if(http.readyState == 4 && http.status == 200) {
 
                                var json=eval('(' +http.responseText+')');
                if(json&&json.d&&json.d.length>0)
                {
                    for(var i=0;i<json.d.length;i++)
                    {
                        if(json.d[i].DaySessionNo=="4"&&json.d[i].TicketTypes)
                        {
                            for(var j=0;j<json.d[i].TicketTypes.length;j++)
                            {
                              au.play();
                             
                                if(intval!="")
                                  clearInterval(intval);
 
                                var ticket=json.d[i].TicketTypes[j];
                                if(ticket)
                                {           
                                    console.log(ticket.SessionID);
                                    console.log(ticket.SessionName);
                                    console.log(ticket.TicketDetail);
                                    console.log(ticket.Time);
                                }
                            }
                        }
                    }
                }
                else
                {
                    console.log('NA at '+Date());
                }
                }
}
http.send(params);
}
,30000)

Revision as of 13:27, 8 September 2010


User scripts, or userscripts, are scripts that make on-the-fly changes to specific web pages on the client side (in the browser or a proxy server), typically to change their appearance or to add or modify functionality.

User scripts for Greasemonkey and Greasemonkey-compatible alternatives are written in JavaScript, but there is at least one example of using another scripting language, namely Ruby in MouseHole.

For tools other than Greasemonkey that apply user scripts to web sites, see Cross-browser Userscripting and Greasmonkey's compatibility.

See Also