Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var packageName = "com.smartphoneremote.androidscriptfree";
- var path = "/store/apps/details";
- var params="id=" + packageName;
- //Called when application is started.
- function OnStart()
- {
- //Create a layout with objects vertically centered.
- lay = app.CreateLayout( "linear", "VCenter,FillXY" );
- //Create a text label and add it to layout.
- txt = app.CreateText( packageName );
- //txt.SetTextSize( 32 );
- lay.AddChild( txt );
- //Add layout to app.
- app.AddLayout( lay );
- app.ShowProgress( null, "NoDim" );
- app.HttpRequest( "GET", "https://play.google.com", path, params, HandleReply, "" );
- }
- function HandleReply( error, response )
- {
- if( !error )
- {
- analyze(response)
- }
- else
- {
- app.HideProgress();
- app.ShowPopup( "Error: " + response);
- }
- }
- function analyze(rst)
- {
- //index of the div tag with ' itemprop="softwareVersion" ' attribute.
- ver_tag_index = rst.indexOf( "itemprop=\"softwareVersion\">" );
- app.HideProgress();
- //If there's no such tag.
- if( ver_tag_index == -1) {
- alert("can't find the version number");
- //Nothing useful ahead. Get out of the function ( won't execute instructions in this function further ).
- return;
- }
- //cut rst from the index of version tag.
- crst = rst.substr( ver_tag_index + 27 );
- //index of first angle bracket in crst.
- angle_index = crst.indexOf("<");
- //cut crst from start to the angi.
- crst = crst.substr(0, angle_index );
- //Remove whitespaces ( if any ) from the beginning and the end of the crst.
- //This is the version number.
- ver_num = crst.trim();
- //If version number "varies with device".
- if( ver_num == "Varies With Device") alert( "Version depends on device");
- txt.SetTextSize( 32 );
- txt.SetText( ver_num );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement