FaizanAnwerAli / Aptoide APK and OBB Online Downloader

// ==UserScript==
// @name            Aptoide APK and OBB Online Downloader
// @version         1.1.1
// @description     Download APK and OBB directly from Aptoide to PC.
// @icon            https://sites.google.com/site/faizanrupani2013/images/Aptoide_Material_Logo_128.png
// @author          Faizan Anwer Ali <faizananwer2011@gmail.com>
// @include         http*://*.aptoide.com/app/market/*
// @include         http*://*.store.aptoide.com/app/market/*
// @exclude         http*://aptoide.com/list/versions/*
// @exclude         http*://*.aptoide.com/list/versions/*
// @exclude         http*://aptoide.com/review/*
// @exclude         http*://*.aptoide.com/review/*
// @exclude         http*://aptoide.com/search/*
// @exclude         http*://*.aptoide.com/search/*
// @exclude         http*://aptoide.com/account/*
// @exclude         http*://*.aptoide.com/account/*
// @exclude         http*://aptoide.com/application/*
// @exclude         http*://*.aptoide.com/application/*
// @exclude         http*://aptoide.com/page/*
// @exclude         http*://*.aptoide.com/page/*
// @exclude         http*://aptoide.com/aptwords/*
// @exclude         http*://*.aptoide.com/aptwords/*
// @require         https://sites.google.com/site/faizanrupani2013/script/jquery.min.js
// @require         https://sites.google.com/site/faizanrupani2013/script/vkbeautify.js
// @require         https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/js/materialize.min.js
// @require         https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js
// @require         https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-animate.min.js
// @require         https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-route.min.js
// @require         https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-aria.min.js
// @require         https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-messages.min.js
// @require         https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js
// @require         https://gitcdn.xyz/repo/angular/bower-material/v0.10.1/angular-material.js
// @require         https://sites.google.com/site/faizanrupani2013/script/jquery.treeview.js
// @require         https://sites.google.com/site/faizanrupani2013/script/download.js
// @require         https://sites.google.com/site/faizanrupani2013/script/shortcut.js
// @grant           GM_info
// @grant           GM_setClipboard
// @grant           GM_xmlhttpRequest
// @grant           GM_addStyle
// @grant           GM_openInTab
// @grant           GM_getValue
// @grant           GM_setValue
// @run-at          document-start
// ==/UserScript==
/* Alternative Links Available here
   ================================
    http://api.burnbit.com/js/button.js
    https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
    https://cdnjs.cloudflare.com/ajax/libs/materialize/0.96.1/js/materialize.min.js
    https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.2/angular.min.js
    https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.2/angular-animate.min.js
    https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.2/angular-route.min.js
    https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.2/angular-aria.min.js
    https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.2/angular-messages.min.js
    https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js
    https://cdnjs.cloudflare.com/ajax/libs/angular-material/0.9.4/angular-material.min.js
    https://sites.google.com/site/faizanrupani2013/script/jquery.treeview.js
    http://danml.com/js/download.js
    http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js
    https://cdnjs.cloudflare.com/ajax/libs/materialize/0.96.1/css/materialize.min.css
    https://cdnjs.cloudflare.com/ajax/libs/angular-material/0.9.4/angular-material.min.css
*/

// http://webservices.aptoide.com/webservices/getApkInfo/androidiyop/com.rockstargames.gtasa/1.07/options=(8047524;cmtlimit=0;subcmtlimit=0)/json
// http://webservices.aptoide.com/webservices/getApkInfo/id:8047524;apkid:com.rockstargames.gtasa;repo:androidiyop/options=(cmtlimit=0;subcmtlimit=0)/xml
// http://webservices.aptoide.com/webservices/getApkInfo/id:8047524;apkid:com.rockstargames.gtasa/options=(vercode=11;cmtlimit=0;subcmtlimit=0)/xml
// http://androidiyop.store.aptoide.com/app/market/com.rockstargames.gtasa/11/8047524/GTA%3A+SA

var startTime = (new Date()).getTime();
document.onreadystatechange = function () {
    if (document.readyState === "interactive") {
        initScript();
    }
};
function initScript() {
    var jsonText, isParsed = false, firstXmlText, newcss, treeviewcss, divnames, appVer, storeName, mainOBBLocation, mainString, patchOBBLocation, patchString, secondXmlLink, secondXmlText, TotalSec, TotalScriptSec, storeFirstLink = "", storeSecondLink = "", storeThirdLink = "", storeFourthLink = "", firstCheckVersion = GM_info.script.version, secondCheckVersion = GM_info.script.version, currentVersion = GM_info.script.version, scriptStartTime = (new Date()).getTime(), array = window.location.toString().split('/'), source = document.documentElement.innerHTML, md5 = source.match(/MD5:<\/strong> [A-Za-z0-9]*/).toString().slice(14), resturl = ( array[array.length-4].toString() + "-" + array[array.length-3].toString() + "-" + array[array.length-2].toString() ).replace(/\./g, "-").replace(/\_/g, "-").replace(/\//g, "-").toLowerCase(), runTimeCheck = parseFloat(GM_getValue("runTimeCheck", 1)), getTotalSecond = parseFloat(GM_getValue("getTotalSecond", 0)), getScriptTotalSecond = parseFloat(GM_getValue("getScriptTotalSecond", 0));
    $('head').append('<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/css/materialize.min.css" media="screen,projection"><link type="text/css" rel="stylesheet" href="https://gitcdn.xyz/repo/angular/bower-material/v0.10.1/angular-material.css">');
    if (window.location.toString().match(/http:\/\/m\./) || window.location.toString().match(/https:\/\/m\./)) {
        if (window.location.protocol === "http:") {
            storeName = window.location.toString().match(/http:\/\/m\.[A-Za-z0-9-_]*\./i).toString().replace(/http:\/\/m./,'').replace(/.$/,'');
        } else {
            storeName = window.location.toString().match(/https:\/\/m\.[A-Za-z0-9-_]*\./i).toString().replace(/https:\/\/m./,'').replace(/.$/,'');
        }
        newcss = '#toast-container { z-index: 1010; } #downloadApkToPC { position: relative; padding-left: 17px; padding-right: 17px; margin-right: 20px;}.modal-trigger.waves-effect.waves-light.btn { padding-left: 17px; padding-right: 17px; position: relative; margin-right: 20px; } .app_view.left{  margin-top: -35px;}.waves-effect.medium.mdi-action-get-app.tooltipped.col.s1,.waves-effect.medium.mdi-action-get-app.tooltipped.disabled.col.s1,.waves-effect.medium.mdi-content-content-copy.tooltipped.col.s1,.waves-effect.medium.mdi-content-content-copy.tooltipped.disabled.col.s1{color:#0d47a1;width:auto;font-size:28px;max-height:40px;margin-top:10px;margin-left:8px;border-radius:5px;border:1px solid #e1e1e1;padding-left:5px;padding-right:5px}.md-tab,input[class=Validate]:disabled,label{-webkit-touch-callout:none}.collapsible{margin:0!important}.tabsdemoDynamicHeight md-content{background-color:transparent!important}.tabsdemoDynamicHeight md-content md-tabs{background:#f6f6f6;border:1px solid #e1e1e1}.tabsdemoDynamicHeight md-content md-tabs md-tabs-canvas{background:#fff}.tabsdemoDynamicHeight md-content h1:first-child{margin-top:0}.md-padding.ng-scope.md-default-theme{overflow-x:auto;overflow-y:auto;max-height:32vh;}.closemodel.tooltipped{color:#fff;width:18px;height:18px;line-height:100%;text-align:center;display:block;position:absolute;opacity:.7;top:12px;right:12px;font-size:18px;text-decoration:none;cursor:pointer}.waves-effect.xmlbutton{color:#0d47a1}.waves-effect.medium.mdi-action-get-app.tooltipped.disabled.col.s1,.waves-effect.medium.mdi-content-content-copy.tooltipped.disabled.col.s1{pointer-events:none;cursor:default;filter:alpha(Opacity=50);opacity:.5}input[class=Validate]:disabled{-khtml-user-select:none;-ms-user-select:none;user-select:none}input[class=Validate]:disabled,label{-webkit-user-select:none;-moz-user-select:none}.disabledValidate{pointer-events:none;cursor:default}label{font-size:16px;-khtml-user-select:none;-ms-user-select:none;user-select:none}[layout-padding],[layout-padding]>[flex-gt-sm],[layout-padding]>[flex-lt-lg],[layout-padding]>[flex-md],[layout-padding]>[flex]{padding:3px!important}.ng-pristine.ng-untouched.ng-valid.md-input{-webkit-touch-callout:none;-khtml-user-select:none;user-select:none}.md-tab,.ng-pristine.ng-untouched.ng-valid.md-input{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.appDetailInfo{height:250px;background:#AB47BC;position:relative;margin-bottom:-100px}.input-field input[type=text]:focus+label{color:#3f51b5}.input-field input[type=text]:focus{border-bottom:1px solid #3f51b5;box-shadow:0 1px 0 0 #3f51b5}.waves-effect.waves-red.btn-large.xmlbutton{//background-image:url(http://library.case.edu/digitalcase/images/doc_xml_icon.png);background-image:url(https://sites.google.com/site/faizanrupani2013/images/doc_xml_icon.png);background-repeat:no-repeat;background-position:17px 14px;background-size:25px 25px;padding-left:55px;color:#212121;background-color:#fff}.treeview ul{background-color:transparent}.treeview li.lastExpandable{background-position:0 -111px}.treeview li.lastCollapsable{background-position:-32px -67px}.filetree span.file,.filetree span.folder{padding:0 0 1px 20px;margin-top:-2px;display:block}.logoimage{height:120px;width:120px;max-height:120px;max-width:120px;margin:20px}.truncate.headingtag{text-shadow:1px 1px #000;position:relative;top:-70px;color:#f5f5f5;font-family:roboto;margin-left:155px;margin-right:17px}.md-tab{-khtml-user-select:none;user-select:none}.md-tab.md-active{cursor:pointer}.md-body-2.right-align.truncate{margin-top:-1px}@media screen and (max-width:600px){.logoimage{height:80px;width:80px;max-height:80px;max-width:80px;margin:15px 10px 10px}.truncate.headingtag{text-shadow:1px 1px #000;position:relative;top:-55px;color:#f5f5f5;font-family:roboto;margin-left:95px;margin-right:17px;font-size:17px}.appDetailInfo{height:200px}}@media screen and (max-width:1440px){.row .col.s10{width:85%}}@media screen and (max-width:1345px){.row .col.s10{width:80%}}@media screen and (max-width:1070px){.row .col.s10{width:78%}}@media screen and (max-width:1015px){.row .col.s10{width:75%}}@media screen and (max-width:1000px){.row .col.s10{width:78%}}@media screen and (max-width:990px){.row .col.s10{width:85%}}@media screen and (max-width:925px){.row .col.s10{width:80%}}@media screen and (max-width:720px){.row .col.s10{width:75%}}@media screen and (max-width:620px){.row .col.s10{width:70%}}@media screen and (max-width:500px){.row .col.s10{width:65%}}@media screen and (max-width:450px){.row .col.s10{width:58%}}@media screen and (max-width:380px){.row .col.s10{width:55%}}@media screen and (max-width:365px){.row .col.s10{width:50%}}';
        treeviewcss = 'md-pagination-wrapper {width: 686px !important;} .md-dialog-container {z-index: 1080;} .md-dialog-container.ng-scope {z-index: 1080;} .burnbit_normal .burnbit_button_text {padding-left: 25px;font-size: 20px;}.burnbit_normal .burnbit_torrent_details {font-size: 13px;padding-left: 25px;}.treeview,.treeview ul{padding:0;margin:0;list-style:none}.treeview ul{background-color:transparent;margin-top:4px}.treeview .hitarea{background:url(https://sites.google.com/site/faizanrupani2013/images/treeview-default.gif) -64px -25px no-repeat;height:16px;width:16px;margin-left:-16px;float:left;cursor:pointer}* html .hitarea{display:inline;float:none}.treeview li{margin:0;padding:3px 0 3px 16px}.treeview a.selected{background-color:#eee}#treecontrol{margin:1em 0;display:none}.treeview .hover{color:red;cursor:pointer}.treeview li{background:url(https://sites.google.com/site/faizanrupani2013/images/treeview-default-line.gif) 0 0 no-repeat}.treeview li.collapsable,.treeview li.expandable{background-position:0 -176px}.treeview .expandable-hitarea{background-position:-80px -3px}.treeview li.last{background-position:0 -1766px}.treeview li.lastCollapsable,.treeview li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-default.gif)}.treeview li.lastCollapsable{background-position:0 -111px}.treeview li.lastExpandable{background-position:-32px -67px}.treeview div.lastCollapsable-hitarea,.treeview div.lastExpandable-hitarea{background-position:0}.treeview-red li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-red-line.gif)}.treeview-red .hitarea,.treeview-red li.lastCollapsable,.treeview-red li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-red.gif)}.treeview-black li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-black-line.gif)}.treeview-black .hitarea,.treeview-black li.lastCollapsable,.treeview-black li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-black.gif)}.treeview-gray li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-gray-line.gif)}.treeview-gray .hitarea,.treeview-gray li.lastCollapsable,.treeview-gray li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-gray.gif)}.treeview-famfamfam li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-famfamfam-line.gif)}.treeview-famfamfam .hitarea,.treeview-famfamfam li.lastCollapsable,.treeview-famfamfam li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-famfamfam.gif)}.treeview .placeholder{background:url(https://sites.google.com/site/faizanrupani2013/images/ajax-loader.gif) 0 0 no-repeat;height:16px;width:16px;display:block}.filetree li{padding:3px 0 2px 16px}.filetree span.folder,.filetree span.file{padding:1px 0 1px 16px;display:block}.filetree span.folder{background:url(https://sites.google.com/site/faizanrupani2013/images/folder.gif) 0 0 no-repeat}.filetree li.expandable span.folder{background:url(https://sites.google.com/site/faizanrupani2013/images/folder-closed.gif) 0 0 no-repeat}.filetree span.file{background:url(https://sites.google.com/site/faizanrupani2013/images/file.gif) 0 0 no-repeat}a.burnbit_compact {height: 25px !important;width: 200px !important;padding-left: 23px !important;line-height: 25px !important;}.burnbit_compact {background-size: 20px !important;font-size: 18px !important;}.burnbit_torrent_details span.s {font-size: 10px;}.burnbit_torrent_details span.p {font-size: 10px;}.btn-flat.waves-effect.medium.mdi-file-cloud-upload.tooltipped{border: 1px solid #e1e1e1;font-size: 30px;}';
        divnames = '.app_meta.install_area:eq(0)';
    } else {
        if (window.location.protocol === "http:") {
            storeName = window.location.toString().match(/http:\/\/[A-Za-z0-9-_]*\./i).toString().replace(/http:\/\//,'').replace(/.$/,'');
        } else {
            storeName = window.location.toString().match(/https:\/\/[A-Za-z0-9-_]*\./i).toString().replace(/https:\/\//,'').replace(/.$/,'');
        }
        newcss = '#toast-container { z-index: 1010; }#downloadApkToPC { position: relative; left: 440px; top: 70px; padding-left: 17px; padding-right: 17px;}.modal-trigger.waves-effect.waves-light.btn { padding-left: 17px; padding-right: 17px; position: relative; top: 70px; left: 415px; } .app_view.left{  margin-top: -35px;}.waves-effect.medium.mdi-action-get-app.tooltipped.col.s1,.waves-effect.medium.mdi-action-get-app.tooltipped.disabled.col.s1,.waves-effect.medium.mdi-content-content-copy.tooltipped.col.s1,.waves-effect.medium.mdi-content-content-copy.tooltipped.disabled.col.s1{color:#0d47a1;width:auto;font-size:28px;max-height:40px;margin-top:10px;margin-left:8px;border-radius:5px;border:1px solid #e1e1e1;padding-left:5px;padding-right:5px}.md-tab,input[class=Validate]:disabled,label{-webkit-touch-callout:none}.collapsible{margin:0!important}.tabsdemoDynamicHeight md-content{background-color:transparent!important}.tabsdemoDynamicHeight md-content md-tabs{background:#f6f6f6;border:1px solid #e1e1e1}.tabsdemoDynamicHeight md-content md-tabs md-tabs-canvas{background:#fff}.tabsdemoDynamicHeight md-content h1:first-child{margin-top:0}.md-padding.ng-scope.md-default-theme{overflow-x:auto;overflow-y:auto;max-height:32vh;}.closemodel.tooltipped{color:#fff;width:18px;height:18px;line-height:100%;text-align:center;display:block;position:absolute;opacity:.7;top:12px;right:12px;font-size:18px;text-decoration:none;cursor:pointer}.waves-effect.xmlbutton{color:#0d47a1}.waves-effect.medium.mdi-action-get-app.tooltipped.disabled.col.s1,.waves-effect.medium.mdi-content-content-copy.tooltipped.disabled.col.s1{pointer-events:none;cursor:default;filter:alpha(Opacity=50);opacity:.5}input[class=Validate]:disabled{-khtml-user-select:none;-ms-user-select:none;user-select:none}input[class=Validate]:disabled,label{-webkit-user-select:none;-moz-user-select:none}.disabledValidate{pointer-events:none;cursor:default}label{font-size:16px;-khtml-user-select:none;-ms-user-select:none;user-select:none}[layout-padding],[layout-padding]>[flex-gt-sm],[layout-padding]>[flex-lt-lg],[layout-padding]>[flex-md],[layout-padding]>[flex]{padding:3px!important}.ng-pristine.ng-untouched.ng-valid.md-input{-webkit-touch-callout:none;-khtml-user-select:none;user-select:none}.md-tab,.ng-pristine.ng-untouched.ng-valid.md-input{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.appDetailInfo{height:250px;background:#AB47BC;position:relative;margin-bottom:-100px}.input-field input[type=text]:focus+label{color:#3f51b5}.input-field input[type=text]:focus{border-bottom:1px solid #3f51b5;box-shadow:0 1px 0 0 #3f51b5}.waves-effect.waves-red.btn-large.xmlbutton{//background-image:url(http://library.case.edu/digitalcase/images/doc_xml_icon.png);background-image:url(https://sites.google.com/site/faizanrupani2013/images/doc_xml_icon.png);background-repeat:no-repeat;background-position:17px 14px;background-size:25px 25px;padding-left:55px;color:#212121;background-color:#fff}.treeview ul{background-color:transparent}.treeview li.lastExpandable{background-position:0 -111px}.treeview li.lastCollapsable{background-position:-32px -67px}.filetree span.file,.filetree span.folder{padding:0 0 1px 20px;margin-top:-2px;display:block}.logoimage{height:120px;width:120px;max-height:120px;max-width:120px;margin:20px}.truncate.headingtag{text-shadow:1px 1px #000;position:relative;top:-70px;color:#f5f5f5;font-family:roboto;margin-left:155px;margin-right:17px}.md-tab{-khtml-user-select:none;user-select:none}.md-tab.md-active{cursor:pointer}.md-body-2.right-align.truncate{margin-top:-1px}@media screen and (max-width:600px){.logoimage{height:80px;width:80px;max-height:80px;max-width:80px;margin:15px 10px 10px}.truncate.headingtag{text-shadow:1px 1px #000;position:relative;top:-55px;color:#f5f5f5;font-family:roboto;margin-left:95px;margin-right:17px;font-size:17px}.appDetailInfo{height:200px}}@media screen and (max-width:1440px){.row .col.s10{width:85%}}@media screen and (max-width:1345px){.row .col.s10{width:80%}}@media screen and (max-width:1070px){.row .col.s10{width:78%}}@media screen and (max-width:1015px){.row .col.s10{width:75%}}@media screen and (max-width:1000px){.row .col.s10{width:78%}}@media screen and (max-width:990px){.row .col.s10{width:85%}}@media screen and (max-width:925px){.row .col.s10{width:80%}}@media screen and (max-width:720px){.row .col.s10{width:75%}}@media screen and (max-width:620px){.row .col.s10{width:70%}}@media screen and (max-width:500px){.row .col.s10{width:65%}}@media screen and (max-width:450px){.row .col.s10{width:58%}}@media screen and (max-width:380px){.row .col.s10{width:55%}}@media screen and (max-width:365px){.row .col.s10{width:50%}}';
        treeviewcss = 'md-pagination-wrapper {width: 686px !important;} .md-dialog-container {z-index: 1080;} .md-dialog-container.ng-scope {z-index: 1080;} .burnbit_normal .burnbit_button_text {padding-left: 25px;font-size: 20px;}.burnbit_normal .burnbit_torrent_details {font-size: 13px;padding-left: 25px;}.treeview,.treeview ul{padding:0;margin:0;list-style:none}.treeview ul{background-color:transparent;margin-top:4px}.treeview .hitarea{background:url(https://sites.google.com/site/faizanrupani2013/images/treeview-default.gif) -64px -25px no-repeat;height:16px;width:16px;margin-left:-16px;float:left;cursor:pointer}* html .hitarea{display:inline;float:none}.treeview li{margin:0;padding:3px 0 3px 16px}.treeview a.selected{background-color:#eee}#treecontrol{margin:1em 0;display:none}.treeview .hover{color:red;cursor:pointer}.treeview li{background:url(https://sites.google.com/site/faizanrupani2013/images/treeview-default-line.gif) 0 0 no-repeat}.treeview li.collapsable,.treeview li.expandable{background-position:0 -176px}.treeview .expandable-hitarea{background-position:-80px -3px}.treeview li.last{background-position:0 -1766px}.treeview li.lastCollapsable,.treeview li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-default.gif)}.treeview li.lastCollapsable{background-position:0 -111px}.treeview li.lastExpandable{background-position:-32px -67px}.treeview div.lastCollapsable-hitarea,.treeview div.lastExpandable-hitarea{background-position:0}.treeview-red li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-red-line.gif)}.treeview-red .hitarea,.treeview-red li.lastCollapsable,.treeview-red li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-red.gif)}.treeview-black li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-black-line.gif)}.treeview-black .hitarea,.treeview-black li.lastCollapsable,.treeview-black li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-black.gif)}.treeview-gray li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-gray-line.gif)}.treeview-gray .hitarea,.treeview-gray li.lastCollapsable,.treeview-gray li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-gray.gif)}.treeview-famfamfam li{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-famfamfam-line.gif)}.treeview-famfamfam .hitarea,.treeview-famfamfam li.lastCollapsable,.treeview-famfamfam li.lastExpandable{background-image:url(https://sites.google.com/site/faizanrupani2013/images/treeview-famfamfam.gif)}.treeview .placeholder{background:url(https://sites.google.com/site/faizanrupani2013/images/ajax-loader.gif) 0 0 no-repeat;height:16px;width:16px;display:block}.filetree li{padding:3px 0 2px 16px}.filetree span.folder,.filetree span.file{padding:1px 0 1px 16px;display:block}.filetree span.folder{background:url(https://sites.google.com/site/faizanrupani2013/images/folder.gif) 0 0 no-repeat}.filetree li.expandable span.folder{background:url(https://sites.google.com/site/faizanrupani2013/images/folder-closed.gif) 0 0 no-repeat}.filetree span.file{background:url(https://sites.google.com/site/faizanrupani2013/images/file.gif) 0 0 no-repeat}a.burnbit_compact {height: 25px !important;width: 200px !important;padding-left: 23px !important;line-height: 25px !important;}.burnbit_compact {background-size: 20px !important;font-size: 18px !important;}.burnbit_torrent_details span.s {font-size: 10px;}.burnbit_torrent_details span.p {font-size: 10px;}.btn-flat.waves-effect.medium.mdi-file-cloud-upload.tooltipped{border: 1px solid #e1e1e1;font-size: 30px;}';
        divnames = '.app_view.left:eq(0) div:eq(0)';
    }
    GM_addStyle(newcss+treeviewcss);
    $(divnames).prepend('<a class="modal-trigger waves-effect waves-light btn" id="optionModel" href="#modal1" style="visibility: hidden;">Options</a><a id="downloadApkToPC" class="waves-effect waves-light btn" style="visibility: hidden;">Download APk</a>');
    var modelDivElement = '<div id="modal1" class="modal"> <div class="appDetailInfo"> <a id="closemodelcrosssign" class="closemodel tooltipped" data-position="bottom" data-delay="50" data-tooltip="Press Esc to Close">&#10005;</a><img class="logoimage" src="http://cdn4.aptoide.com/imgs/9/f/7/9f71e5aa68c2297a39c6966fa6dc80d7_icon_127x127.png" ondragstart="return false;"> <h5 class="truncate headingtag">Delayed Lock Location Plugin Patched + Maps not Working</h5> </div> <div class="tabsdemoDynamicHeight" ng-app="MyApp" ng-controller="SwitchDemoCtrl"> <md-content class="md-padding"> <md-tabs md-dynamic-height md-border-bottom md-selected="selectedIndex"> <md-tab label="Direct Downloads"> <md-content class="md-padding"> <div class="row" id="downloadFirstRow"> <div class="input-field col s10"> <input value="[Empty]" id="apkLink" type="text" class="Validate"> <label for="apkLink">APK Download Link</label> </div> <a id="firstCopy" class="waves-effect medium mdi-content-content-copy tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Copy APK Link"></a> <a id="firstDownload" class="waves-effect medium mdi-action-get-app tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Download APK"></a> </div> <div class="row" id="downloadSecondRow"> <div class="input-field col s10"> <input value="[Empty]" id="alternativeLink" type="text" class="Validate"> <label for="alternativeLink">Alternative APK Download Link</label> </div> <a id="secondCopy" class="waves-effect medium mdi-content-content-copy tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Copy Alternative APK Link"></a> <a id="secondDownload" class="waves-effect medium mdi-action-get-app tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Download Alternative Link APK"></a> </div> <div class="row" id="downloadThirdRow"> <div class="input-field col s10"> <input value="[Empty]" id="mainObbLink" type="text" class="Validate"> <label for="mainObbLink">Main OBB Link</label> </div> <a id="thirdCopy" class="waves-effect medium mdi-content-content-copy tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Copy Main OBB Link"></a> <a id="thirdDownload" class="waves-effect medium mdi-action-get-app tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Download Main OBB"></a> </div> <div class="row" id="downloadFourthRow"> <div class="input-field col s10"> <input value="[Empty]" id="patchObbLink" type="text" class="Validate"> <label for="patchObbLink">Patch OBB Link</label> </div> <a id="fourthCopy" class="waves-effect medium mdi-content-content-copy tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Copy Patch OBB Link"></a> <a id="fourthDownload" class="waves-effect medium mdi-action-get-app tooltipped col s1" data-position="top" data-delay="50" data-tooltip="Download Patch OBB"></a> </div> </md-content> </md-tab> <md-tab label="Other"> <md-content class="md-padding"> <div class="row" id="optionFirstRow"> <div class="input-field col s6"> <input value="[Empty]" id="apkName" type="text" class="Validate"> <label for="apkLink">Name of APK</label> </div> <div class="input-field col s3" style="border: 1px solid #e1e1e1;height: 37px;" id="firstTorrentButtonDiv"> </div> <div class="input-field col s2"> <a onclick="return false;" class="btn-flat waves-effect medium mdi-file-cloud-upload tooltipped" ng-click="showAdvanced($event)" data-position="top" data-delay="50" data-tooltip="Upload APK to Cloud" href="[Empty]"></a> </div> </div> <div class="row" id="optionSecondRow"> <div class="input-field col s6"> <input value="[Empty]" id="mainObbName" type="text" class="Validate"> <label for="mainObbLink">Name of Main OBB</label> </div> <div class="input-field col s3" style="border: 1px solid #e1e1e1;height: 37px;" id="secondTorrentButtonDiv"> </div> <div class="input-field col s2"> <a onclick="return false;" class="btn-flat waves-effect medium mdi-file-cloud-upload tooltipped" ng-click="showAdvanced($event)" data-position="top" data-delay="50" data-tooltip="Upload Main OBB to Cloud" href="[Empty]"></a> </div> </div> <div class="row" id="optionThirdRow"> <div class="input-field col s6"> <input value="[Empty]" id="patchObbName" type="text" class="Validate"> <label for="patchObbLink">Name of Patch OBB</label> </div> <div class="input-field col s3" style="border: 1px solid #e1e1e1;height: 37px;" id="thirdTorrentButtonDiv"> </div> <div class="input-field col s2"> <a onclick="return false;" class="btn-flat waves-effect medium mdi-file-cloud-upload tooltipped" ng-click="showAdvanced($event)" data-position="top" data-delay="50" data-tooltip="Upload Patch OBB to Cloud" href="[Empty]"></a> </div> </div> </md-content> </md-tab> <md-tab label="Instructions"> <md-content class="md-padding"> <ul class="collapsible popout" data-collapsible="accordion"> <li> <div class="collapsible-header truncate"><i class="mdi-action-info-outline"></i>Shortcut keys Overview</div> <div class="collapsible-body"> <div style=" margin-left: 20px;margin-right: 20px;margin-bottom: -2px;"> <table style="margin-bottom: 20px; margin-top: 10px; padding-top: 10px;" class="striped responsive-table hoverable bordered"> <thead> <tr style="font-size: 16px;"> <th style="padding-left: 15px;">Press</th> <th>To</th> </tr> </thead> <tbody> <tr> <td style="padding-left: 15px;">Shift+D</td> <td>Download Apk.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+A</td> <td>Download Alternative Apk.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+M</td> <td>Download Main OBB file.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+P</td> <td>Download Patch OBB file.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+Alt+D</td> <td>Copy Apk Link.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+Alt+A</td> <td>Copy Alternative Apk Link.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+Alt+M</td> <td>Copy Main OBB file Link.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+Alt+P</td> <td>Copy Patch OBB file Link.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+1</td> <td>Download First XML file.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+2</td> <td>Download Second XML file.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+3</td> <td>Download JSON file.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+4</td> <td>Copy First XML Link.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+5</td> <td>Copy Second XML Link.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+6</td> <td>Copy JSON Link.</td> </tr> <tr> <td style="padding-left: 15px;">Shift+7</td> <td>View XML File Online</td> </tr> <tr> <td style="padding-left: 15px;">Shift+8</td> <td>View Alternative XML File Online</td> </tr> <tr> <td style="padding-left: 15px;">Shift+9</td> <td>View JSON File Online</td> </tr> <tr> <td style="padding-left: 15px;">Shift+0</td> <td>View Alternative JSON File Online</td> </tr> <tr> <td style="padding-left: 15px;">Shift+R</td> <td>Reset Script Timing. <br>(Check Script Info Tab)</td> </tr> <tr> <td style="padding-left: 15px;">Shift+O</td> <td>Open this Model.</td> </tr> <tr> <td style="padding-left: 15px;">Esc</td> <td>Close this Modal.</td> </tr> </tbody> </table> </div> </div> </li> <li> <div class="collapsible-header truncate"><i class="mdi-action-info-outline"></i>How to Install APK:</div> <div class="collapsible-body"> <ol type="1" style="line-height: 1.5;margin-left: 35px;margin-top: 15px;margin-right: 15px;margin-bottom: 15px;"> <li style="list-style-type: decimal;"><b>Requirements:</b> <ul style="list-style-type:disc;margin-left: 30px;"> <li style="list-style-type: inherit;text-align: justify;">Android Device</li> </ul> </li> <br> <li style="list-style-type: decimal;"><b>Steps Overview:</b> <ul style="list-style-type:disc;margin-left: 30px;"> <li style="list-style-type: inherit;text-align: justify;">Enable "Unknown Sources" on Android.</li> <li style="list-style-type: inherit;text-align: justify;">Download Apk from here.</li> <li style="list-style-type: inherit;text-align: justify;">Move it in you Device using any File Explorer.</li> <li style="list-style-type: inherit;text-align: justify;">Once in the directory, tap the APK icon and an installation dialogue box will pop-up.</li> <li style="list-style-type: inherit;text-align: justify;">Hit the install button to install the APK on your Android.</li> <li style="list-style-type: inherit;text-align: justify;">For more Info, Goto <a style="color: blue;" href="http://www.ubergizmo.com/how-to/how-to-install-apk-files-sideloading-on-android/">UBERGIZMO.COM</a> or <a style="color: blue;" href="http://www.cnet.com/how-to/how-to-install-apps-outside-of-google-play/">CNET.COM</a> or <a style="color: blue;" href="http://papidroid.com/2013/12/12/how-to-install-apk-files-on-your-android-phone-or-tablet/">PAPIDROID.COM</a></li> </ul> </li> </ol> </div> </li> <li> <div class="collapsible-header truncate"><i class="mdi-action-info-outline"></i>How to Download OBB Files</div> <div class="collapsible-body"> <ol id="downloadObbOl" type="1" style="line-height: 1.5;margin-left: 35px;margin-top: 15px;margin-right: 15px;margin-bottom: 15px;"> <li style="list-style-type: decimal;"><b style="font-size: 15px;">Steps to Download Main OBB File:</b> <ul style="list-style-type:disc;margin-left: 30px;"> <li style="list-style-type: inherit;">Download Main OBB from here.</li> <li style="list-style-type: inherit;">You\'ll get "<span id="beforeMainObbName" style="color: #e65100;">[Empty]</span>" file from direct download.</li> <li style="list-style-type: inherit;">If you\'re using IDM, you\'ll get "<span id="IdmMainObbName" style="color: #e65100;">[Empty]</span>" file.</li> <li style="list-style-type: inherit;">After Download rename it to "<span class="AfterMainObbName" style="color: #00c853;">[Empty]</span>".</li> <li style="list-style-type: inherit;">If you\'re having trouble in renaming, Enable File Extension View in your Windows Operating System.</li> <li style="list-style-type: inherit;">Follow these steps to view file extension in windows 7 from <a style="color: blue;" href="http://windows.microsoft.com/en-us/windows/show-hide-file-name-extensions#show-hide-file-name-extensions=windows-7">WINDOWS.MICROSOFT.COM</a>.</li> <li style="list-style-type: inherit;">Or in Windows 8 and 8.1 from <a style="color: blue;" href="http://www.eightforums.com/tutorials/30434-file-name-extensions-hide-show-windows-8-a.html">EIGHTFORUMS.COM</a>.</li> <li style="list-style-type: inherit;">For more Info about this error, Goto <a style="color: blue;" href="http://forum.mobilism.org/viewtopic.php?p=2586631#p2586631">FORUM.MOBILISM.ORG</a></li> </ul> </li> <br> <li style="list-style-type: decimal;" id="PatchDownloadSteps"><b style="font-size: 15px;">Steps to Download Patch OBB File:</b> <ul style="list-style-type:disc;margin-left: 30px;"> <li style="list-style-type: inherit;">Download Patch OBB from here.</li> <li style="list-style-type: inherit;">You\'ll get "<span id="beforePatchObbName" style="color: #e65100;">[Empty]</span>" file from direct download.</li> <li style="list-style-type: inherit;">If you\'re using IDM, you\'ll get "<span id="IdmPatchObbName" style="color: #e65100;">[Empty]</span>" file.</li> <li style="list-style-type: inherit;">After Download rename it to "<span class="AfterPatchObbName" style="color: #00c853;">[Empty]</span>".</li> <li style="list-style-type: inherit;">If you\'re having trouble in renaming, Enable File Extension View in your Windows Operating System.</li> <li style="list-style-type: inherit;">Follow these steps to view file extension in windows 7 from <a style="color: blue;" href="http://windows.microsoft.com/en-us/windows/show-hide-file-name-extensions#show-hide-file-name-extensions=windows-7">WINDOWS.MICROSOFT.COM</a>.</li> <li style="list-style-type: inherit;">Or in Windows 8 and 8.1 from <a style="color: blue;" href="http://www.eightforums.com/tutorials/30434-file-name-extensions-hide-show-windows-8-a.html">EIGHTFORUMS.COM</a>.</li> <li style="list-style-type: inherit;">For more Info about this error, Goto <a style="color: blue;" href="http://forum.mobilism.org/viewtopic.php?p=2586631#p2586631">FORUM.MOBILISM.ORG</a></li> </ul> </li> </ol> <p class="NoObbFileNotify">No Obb File Available.</p> </div> </li> <li> <div class="collapsible-header truncate"><i class="mdi-action-info-outline"></i>How to Install OBB Files</div> <div class="collapsible-body" style="overflow-x:auto;margin-right:10px"> <ol id="installObbOl" type="1" style="line-height: 1.5;margin-left: 35px;margin-top: 15px;margin-right: 15px;margin-bottom: 15px;"> <li style="list-style-type: decimal;"><b style="font-size: 15px;">Steps to Install OBB Files:</b> <ul style="list-style-type:disc;margin-left: 30px;"> <li style="list-style-type: inherit;">After Downloading OBB files, Create a folder <span id="PackageName" style="color: #039be5;">[Empty]</span> in <span style="color: #00897b;">SD Card &gt; Android &gt; Obb</span> folder.</li> <li style="list-style-type: inherit;" id="transferMain">Transfer "<span class="AfterMainObbName" style="color: #ef6c00;">[Empty]</span>" file in it using any File Explorer.</li> <li style="list-style-type: inherit;" id="transferPatch">Transfer "<span class="AfterMainObbName" style="color: #ef6c00;">[Empty]</span>" and "<span class="AfterPatchObbName" style="color: #ef6c00;">[Empty]</span>" files in it using any File Explorer.</li> <li style="list-style-type: inherit;">Once in the directory, Install APK using above method.</li> <li style="list-style-type: inherit;">For more Info about installing OBB files, Goto <a style="color: blue;" href="http://canvas2update.blogspot.com/2014/01/how-to-install-android-games-with-data.html">CANVAS2UPDATE.BLOGSPOT.COM</a></li> </ul> </li> <br> <li style="list-style-type: decimal;"><b style="font-size: 15px;">Graphical Folder View:</b> <ul id="browser" class="filetree" style="margin-top: 5px;"> <li><span class="folder">SD Card</span> <ul> <li><span class="folder">Android</span> <ul> <li><span class="folder">Obb</span> <ul> <li><span class="folder" id="treviewPackageName">[Empty]</span> <ul> <li><span class="file" id="treeviewMainObbName">{Empty}</span></li> <li id="LastTreeviewFile"><span class="file" id="treeviewPatchObbName">{Empty}</span></li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> </ol> <p class="NoObbFileNotify">No Obb File Available.</p> </div> </li> <li> <div class="collapsible-header truncate"><i class="mdi-action-info-outline"></i>How to upload on Cloud Server</div> <div class="collapsible-body"> <ol type="1" style="line-height: 1.5;margin-left: 35px;margin-top: 15px;margin-right: 15px;margin-bottom: 15px;"> <li style="list-style-type: decimal;"><b style="font-size: 15px;">Steps to Upload Files to CLoud Servers:</b> <ul style="list-style-type:disc;margin-left: 30px;"> <li style="list-style-type: inherit;">First Install <a style="color: blue;" href="https://chrome.google.com/webstore/detail/ballloon-for-chrome/kbmligehjhghebleanjcmenomghmcohn">Ballloon Extension for Chrome</a>. (Only work with Chrome Browser)</li> <li style="list-style-type: inherit;">Goto <span style="color: #00c853;">Other</span> tab.</li> <li style="list-style-type: inherit;">Right Click on <span style="color: #e65100;">Cloud Button</span>. (Left Click is Disabled)</li> <li style="list-style-type: inherit;">Select <span style="color: #00897b;">Save link to</span>, then select any <span style="color: #039be5;">Cloud Server</span> for upload.</li> <li style="list-style-type: inherit;">See Images Below.</li> </ul> </li> <br> <li style="list-style-type: decimal;"><b style="font-size: 15px;">Instructions in Images</b> <ul style="list-style-type:disc;margin-left: 30px;"> <li style="list-style-type: inherit;"><a style="color: blue;" href="https://sites.google.com/site/faizanrupani2013/images/Cloud-Instructions-1.PNG" target="_blank">Cloud-Instructions-1.png</a></li> <li style="list-style-type: inherit;"><a style="color: blue;" href="https://sites.google.com/site/faizanrupani2013/images/Cloud-Instructions-2.PNG" target="_blank">Cloud-Instructions-2.png</a></li> <li style="list-style-type: inherit;"><a style="color: blue;" href="https://sites.google.com/site/faizanrupani2013/images/Cloud-Instructions-3.PNG" target="_blank">Cloud-Instructions-3.png</a></li> <li style="list-style-type: inherit;"><a style="color: blue;" href="https://sites.google.com/site/faizanrupani2013/images/Cloud-Instructions-4.PNG" target="_blank">Cloud-Instructions-4.png</a></li> </ul> </li> </ol> </div> </li> </ul> </md-content> </md-tab> <md-tab label="Extra Files"> <md-content class="md-padding"><a class="waves-effect waves-red btn-large xmlbutton" id="downloadFirstXML">Download First XML File</a> <br> <br> <a class="waves-effect waves-red btn-large xmlbutton" id="downloadSecondXML">Download Second XML File</a> <br> <br> <a class="waves-effect waves-red btn-large xmlbutton" id="downloadJson">Download JSON File</a> <br> <br> <a class="waves-effect waves-red btn-large xmlbutton" id="xmlOnline" target="_blank">View XML Online</a> <br> <br> <a class="waves-effect waves-red btn-large xmlbutton" id="altXmlOnline" target="_blank">View Alternative Xml link Online</a> <br> <br> <a class="waves-effect waves-red btn-large xmlbutton" id="jsonOnline" target="_blank">View JSON Online</a> <br> <br> <a class="waves-effect waves-red btn-large xmlbutton" id="jsonAltOnline" target="_blank">View Alternative JSON link Online</a> </md-content> </md-tab> <md-tab label="Script Info"> <md-content class="md-padding"> <h3 class="md-display-1" style="color:#26a69a !important;font-size: 26px !important;">Script Version:</h3> <ul style="list-style-type:disc;margin-left: 30px;margin-bottom: 25px;" id="needUpdateUL"> </ul> <a id="needUpdateButton" class="modal-trigger waves-effect waves-light btn" href="https://openuserjs.org/scripts/FaizanAnwerAli/Aptoide_APK_and_OBB_Online_Downloader" target="_blank" style="margin-left:30px; margin-top:-15px; margin-bottom: 15px; top: 0; left: 0;">Update Script</a> <ul style="list-style-type:disc;margin-left: 30px;margin-bottom: 25px;" id="updatedUL"> </ul> <h3 class="md-display-1" style="color:#26a69a !important;font-size: 26px !important;">Script Timings:</h3> <ul style="list-style-type:disc;margin-left: 30px;margin-bottom: 25px;"> <li style="list-style-type: inherit;" id="firstTime"></li> <li style="list-style-type: inherit;" id="secondTime"></li> <li style="list-style-type: inherit;" id="thirdTime"></li> <li style="list-style-type: inherit;" id="fourthTime"></li> <li style="list-style-type: inherit;" id="fifthTime"></li> </ul><a id="resetTiming" class="waves-effect waves-light btn" style="margin-left: 30px; margin-top: -15px; margin-bottom: 15px; top: 0px; left: 0px;">Reset Timings</a> <h3 class="md-display-1" style="color:#26a69a !important;font-size: 26px !important;">ChangeLog:</h3> <ol class="scriptOL" style="margin-top: -20px;"></ol> </md-content> </md-tab> </md-tabs> </md-content> <script type="text/ng-template" id="dialog1.tmpl.html"> <md-dialog aria-label="Left Click is Disabled"> <form> <md-toolbar> <div class="md-toolbar-tools"> <h2>Left Click is Disabled</h2> </div> </md-toolbar> <md-dialog-content> <div> <p>Right Click to Save File to Cloud Server using <b>Ballloon Extension for Chrome</b>. <br>For More Info Goto <b>Instructions Tab</b> > <b>How to upload on Cloud Server</b></p> </div> </md-dialog-content> <div class="md-actions" layout="row"> <span flex></span> <md-button ng-click="answer(\'useful\')" class="md-primary"> GOT IT! </md-button> </div> </form> </md-dialog> </script> </div></div><div id="modal2" class="modal"> <md-toolbar class="md-default-theme"> <div class="md-toolbar-tools"> <h2>Update Available</h2> </div> </md-toolbar> <p style="padding: 24px;" id="updateNotificationText"></p> <div class="modal-footer"> <a class="modal-action modal-close waves-effect waves-green btn-flat" style="margin:5px;">Close</a> <a class="waves-effect waves-green btn-flat" style="margin:5px;" href="https://openuserjs.org/scripts/FaizanAnwerAli/Aptoide_APK_and_OBB_Online_Downloader" target="_blank">Update Script</a> </div></div><script src="http://api.burnbit.com/js/button.js" type="text/javascript"></script>';
    $('body').append(modelDivElement);
    document.getElementsByClassName('logoimage')[0].src = document.getElementsByClassName('app_icon')[0].src;
    document.getElementsByClassName('truncate headingtag')[0].innerHTML = document.getElementsByClassName('app_name')[0].innerHTML;
    try {
        appVer = source.match(/VersiĆ³n: ([\s]?[A-Z]?[a-z]?[0-9]?[.]?[-]?[_]?)*/).toString().slice(9).replace(/^\s|\s*\,\s*$/gm,'');
    } catch(err) {
        appVer = source.match(/Version: ([\s]?[A-Z]?[a-z]?[0-9]?[.]?[-]?[_]?)*/).toString().slice(9).replace(/^\s|\s*\,\s*$/gm,'');
    }
    var xml = 'http://www.aptoide.com/webservices/getApkInfo/' + storeName + '/' + array[array.length-4].toString() + '/' + appVer + '/xml';
    var json = 'http://www.aptoide.com/webservices/getApkInfo/' + storeName + '/' + array[array.length-4].toString() + '/' + appVer + '/json';
    var xml2 = 'http://webservices.aptoide.com/webservices/2/getApkInfo/id:' + array[array.length-2].toString() + '/xml';
    var json2 = 'http://webservices.aptoide.com/webservices/2/getApkInfo/id:' + array[array.length-2].toString() + '/json';
    document.getElementsByClassName('waves-effect waves-red btn-large xmlbutton')[3].href = xml;
    document.getElementsByClassName('waves-effect waves-red btn-large xmlbutton')[4].href = xml2;
    document.getElementsByClassName('waves-effect waves-red btn-large xmlbutton')[5].href = json;
    document.getElementsByClassName('waves-effect waves-red btn-large xmlbutton')[6].href = json2;
    GM_xmlhttpRequest({
        method: "GET",
        url: xml.replace(/ /,'%2520'),
        onload: function(xhReq) {
            if (xhReq.statusText === "OK") {
                firstXmlText = xhReq.responseText;
                var XMLdata = xhReq.responseXML;
                storeFirstLink = XMLdata.getElementsByTagName("path")[0].innerHTML;
                storeSecondLink = XMLdata.getElementsByTagName("altpath")[0].innerHTML;
                document.getElementById("apkLink").value = storeFirstLink;
                document.getElementById("alternativeLink").value = storeSecondLink;
                document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[0].href = storeFirstLink;
                document.getElementById("firstTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Apk From Torrent" burnbit_file="' + storeFirstLink + '" burnbit_style="normal"></a>';
                if (XMLdata.getElementsByTagName("patch").length == 1) {
                    storeThirdLink = XMLdata.getElementsByTagName("main")[0].getElementsByTagName("path")[0].innerHTML;
                    storeFourthLink = XMLdata.getElementsByTagName("patch")[0].getElementsByTagName("path")[0].innerHTML;
                    document.getElementById("mainObbLink").value = storeThirdLink;
                    document.getElementById("patchObbLink").value = storeFourthLink;
                    document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[1].href = storeThirdLink;
                    document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[2].href = storeFourthLink;
                    document.getElementById("mainObbName").value = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementById("patchObbName").value = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                    document.getElementsByClassName("NoObbFileNotify")[0].style.display = "none";
                    document.getElementsByClassName("NoObbFileNotify")[1].style.display = "none";
                    mainOBBLocation = storeThirdLink.split('/');
                    mainString = mainOBBLocation[mainOBBLocation.length-1].toString();
                    document.getElementById("beforeMainObbName").innerHTML = mainString;
                    document.getElementById("IdmMainObbName").innerHTML = mainString.slice(0, mainString.length-4) + ".zip";
                    patchOBBLocation = storeFourthLink.split('/');
                    patchString = patchOBBLocation[patchOBBLocation.length -1].toString();
                    document.getElementById("beforePatchObbName").innerHTML = patchString;
                    document.getElementById("IdmPatchObbName").innerHTML = patchString.slice(0, patchString.length-4) + ".zip";
                    document.getElementsByClassName("AfterMainObbName")[0].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementsByClassName("AfterMainObbName")[2].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementsByClassName("AfterPatchObbName")[0].innerHTML = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                    document.getElementsByClassName("AfterPatchObbName")[1].innerHTML = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                    document.getElementById("PackageName").innerHTML = array[array.length-4].toString();
                    document.getElementById("transferMain").style.display = "none";
                    document.getElementById("treviewPackageName").innerHTML = array[array.length-4].toString();
                    document.getElementById("treeviewMainObbName").innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementById("treeviewPatchObbName").innerHTML = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                    document.getElementById("secondTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Main OBB From Torrent" burnbit_file="' + storeThirdLink + '" burnbit_style="normal"></a>';
                    document.getElementById("thirdTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Patch OBB From Torrent" burnbit_file="' + storeFourthLink + '" burnbit_style="normal"></a>';
                } else if (XMLdata.getElementsByTagName("main").length == 1) {
                    storeThirdLink = XMLdata.getElementsByTagName("main")[0].getElementsByTagName("path")[0].innerHTML;
                    document.getElementById("mainObbLink").value = storeThirdLink;
                    document.getElementById("downloadFourthRow").style.display = "none";
                    document.getElementById("optionThirdRow").style.display = "none";
                    document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[1].href = storeThirdLink;
                    document.getElementById("mainObbName").value = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementsByClassName("NoObbFileNotify")[0].style.display = "none";
                    document.getElementsByClassName("NoObbFileNotify")[1].style.display = "none";
                    document.getElementById("PatchDownloadSteps").style.display = "none";
                    mainOBBLocation = storeThirdLink.split('/');
                    mainString = mainOBBLocation[mainOBBLocation.length - 1].toString();
                    document.getElementById("beforeMainObbName").innerHTML = mainString;
                    document.getElementById("IdmMainObbName").innerHTML = mainString.slice(0, mainString.length-4) + ".zip";
                    document.getElementsByClassName("AfterMainObbName")[0].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementsByClassName("AfterMainObbName")[1].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementById("PackageName").innerHTML = array[array.length-4].toString();
                    document.getElementById("transferPatch").style.display = "none";
                    document.getElementById("treviewPackageName").innerHTML = array[array.length-4].toString();
                    document.getElementById("treeviewMainObbName").innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                    document.getElementById("LastTreeviewFile").style.display = "none";
                    document.getElementById("secondTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Main OBB From Torrent" burnbit_file="' + storeThirdLink + '" burnbit_style="normal"></a>';
                } else {
                    document.getElementById("downloadThirdRow").style.display = "none";
                    document.getElementById("downloadFourthRow").style.display = "none";
                    document.getElementById("optionSecondRow").style.display = "none";
                    document.getElementById("optionThirdRow").style.display = "none";
                    document.getElementById("downloadObbOl").style.display = "none";
                    document.getElementById("installObbOl").style.display = "none";
                    document.getElementsByClassName("NoObbFileNotify")[0].style.display = "visible";
                    document.getElementsByClassName("NoObbFileNotify")[1].style.display = "visible";
                }
            } else {
                GM_xmlhttpRequest({
                    method: "GET",
                    url: xml2.replace(/ /,'%2520'),
                    onload: function(xhReq) {
                        if (xhReq.statusText === "OK") {
                            firstXmlText = xhReq.responseText;
                            var XMLdata = xhReq.responseXML;
                            storeFirstLink = XMLdata.getElementsByTagName("path")[0].innerHTML;
                            storeSecondLink = XMLdata.getElementsByTagName("altpath")[0].innerHTML;
                            document.getElementById("apkLink").value = storeFirstLink;
                            document.getElementById("alternativeLink").value = storeSecondLink;
                            document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[0].href = storeFirstLink;
                            document.getElementById("firstTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Apk From Torrent" burnbit_file="' + storeFirstLink + '" burnbit_style="normal"></a>';
                            if (XMLdata.getElementsByTagName("patch").length == 1) {
                                storeThirdLink = XMLdata.getElementsByTagName("main")[0].getElementsByTagName("path")[0].innerHTML;
                                storeFourthLink = XMLdata.getElementsByTagName("patch")[0].getElementsByTagName("path")[0].innerHTML;
                                document.getElementById("mainObbLink").value = storeThirdLink;
                                document.getElementById("patchObbLink").value = storeFourthLink;
                                document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[1].href = storeThirdLink;
                                document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[2].href = storeFourthLink;
                                document.getElementById("mainObbName").value = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementById("patchObbName").value = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                                document.getElementsByClassName("NoObbFileNotify")[0].style.display = "none";
                                document.getElementsByClassName("NoObbFileNotify")[1].style.display = "none";
                                mainOBBLocation = storeThirdLink.split('/');
                                mainString = mainOBBLocation[mainOBBLocation.length-1].toString();
                                document.getElementById("beforeMainObbName").innerHTML = mainString;
                                document.getElementById("IdmMainObbName").innerHTML = mainString.slice(0, mainString.length-4) + ".zip";
                                patchOBBLocation = storeFourthLink.split('/');
                                patchString = patchOBBLocation[patchOBBLocation.length -1].toString();
                                document.getElementById("beforePatchObbName").innerHTML = patchString;
                                document.getElementById("IdmPatchObbName").innerHTML = patchString.slice(0, patchString.length-4) + ".zip";
                                document.getElementsByClassName("AfterMainObbName")[0].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementsByClassName("AfterMainObbName")[2].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementsByClassName("AfterPatchObbName")[0].innerHTML = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                                document.getElementsByClassName("AfterPatchObbName")[1].innerHTML = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                                document.getElementById("PackageName").innerHTML = array[array.length-4].toString();
                                document.getElementById("transferMain").style.display = "none";
                                document.getElementById("treviewPackageName").innerHTML = array[array.length-4].toString();
                                document.getElementById("treeviewMainObbName").innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementById("treeviewPatchObbName").innerHTML = XMLdata.getElementsByTagName("filename")[1].innerHTML;
                                document.getElementById("secondTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Main OBB From Torrent" burnbit_file="' + storeThirdLink + '" burnbit_style="normal"></a>';
                                document.getElementById("thirdTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Patch OBB From Torrent" burnbit_file="' + storeFourthLink + '" burnbit_style="normal"></a>';
                            } else if (XMLdata.getElementsByTagName("main").length == 1) {
                                storeThirdLink = XMLdata.getElementsByTagName("main")[0].getElementsByTagName("path")[0].innerHTML;
                                document.getElementById("mainObbLink").value = storeThirdLink;
                                document.getElementById("downloadFourthRow").style.display = "none";
                                document.getElementById("optionThirdRow").style.display = "none";
                                document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[1].href = storeThirdLink;
                                document.getElementById("mainObbName").value = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementsByClassName("NoObbFileNotify")[0].style.display = "none";
                                document.getElementsByClassName("NoObbFileNotify")[1].style.display = "none";
                                document.getElementById("PatchDownloadSteps").style.display = "none";
                                mainOBBLocation = storeThirdLink.split('/');
                                mainString = mainOBBLocation[mainOBBLocation.length - 1].toString();
                                document.getElementById("beforeMainObbName").innerHTML = mainString;
                                document.getElementById("IdmMainObbName").innerHTML = mainString.slice(0, mainString.length-4) + ".zip";
                                document.getElementsByClassName("AfterMainObbName")[0].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementsByClassName("AfterMainObbName")[1].innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementById("PackageName").innerHTML = array[array.length-4].toString();
                                document.getElementById("transferPatch").style.display = "none";
                                document.getElementById("treviewPackageName").innerHTML = array[array.length-4].toString();
                                document.getElementById("treeviewMainObbName").innerHTML = XMLdata.getElementsByTagName("filename")[0].innerHTML;
                                document.getElementById("LastTreeviewFile").style.display = "none";
                                document.getElementById("secondTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Main OBB From Torrent" burnbit_file="' + storeThirdLink + '" burnbit_style="normal"></a>';
                            } else {
                                document.getElementById("downloadThirdRow").style.display = "none";
                                document.getElementById("downloadFourthRow").style.display = "none";
                                document.getElementById("optionSecondRow").style.display = "none";
                                document.getElementById("optionThirdRow").style.display = "none";
                                document.getElementById("downloadObbOl").style.display = "none";
                                document.getElementById("installObbOl").style.display = "none";
                                document.getElementsByClassName("NoObbFileNotify")[0].style.display = "visible";
                                document.getElementsByClassName("NoObbFileNotify")[1].style.display = "visible";
                            }
                        } else {
                            for (var i = 0; i <= 3; i++) {
                                var xmlUrl = "http://imgs.aptoide.com/apks/" + i + "/aptoide-f63c6f2461f65f32b6d144d6d2ff982e/" + storeName + "/" + resturl + ".myapp";
                                sceondXMLParsing(xmlUrl);
                            }
                        }
                    }
                });
            }
        }
    });
    function sceondXMLParsing (xmlUrl){
        GM_xmlhttpRequest({
            method: "GET",
            url: xmlUrl,
            onload: function(xhr) {
                if (xhr.statusText === "OK") {
                    isParsed = true;
                    secondXmlText = xhr.responseText;
                    secondXmlLink = xmlUrl;
                    var XMdata = jQuery.parseXML(xhr.responseText);
                    storeFirstLink = XMdata.getElementsByTagName("get")[0].innerHTML;
                    document.getElementById("apkLink").value = XMdata.getElementsByTagName("get")[0].innerHTML;
                    document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[0].href = XMdata.getElementsByTagName("get")[0].innerHTML;
                    document.getElementById("firstTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Apk From Torrent" burnbit_file="' + XMdata.getElementsByTagName("get")[0].innerHTML + '" burnbit_style="normal"></a>';
                    if (XMdata.getElementsByTagName("patch_path").length == 1) {
                        storeThirdLink = XMdata.getElementsByTagName("main_path")[0].innerHTML;
                        storeFourthLink = XMdata.getElementsByTagName("patch_path")[0].innerHTML;
                        document.getElementById("mainObbLink").value = XMdata.getElementsByTagName("main_path")[0].innerHTML;
                        document.getElementById("patchObbLink").value = XMdata.getElementsByTagName("patch_path")[0].innerHTML;
                        document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[1].href = XMdata.getElementsByTagName("main_path")[0].innerHTML;
                        document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[2].href = XMdata.getElementsByTagName("patch_path")[0].innerHTML;
                        document.getElementById("mainObbName").value = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementById("patchObbName").value = XMdata.getElementsByTagName("patch_filename")[0].innerHTML;
                        document.getElementsByClassName("NoObbFileNotify")[0].style.display = "none";
                        document.getElementsByClassName("NoObbFileNotify")[1].style.display = "none";
                        mainOBBLocation = XMdata.getElementsByTagName("main_path")[0].innerHTML.split('/');
                        mainString = mainOBBLocation[mainOBBLocation.length-1].toString();
                        document.getElementById("beforeMainObbName").innerHTML = mainString;
                        document.getElementById("IdmMainObbName").innerHTML = mainString.slice(0, mainString.length-4) + ".zip";
                        patchOBBLocation = XMdata.getElementsByTagName("patch_path")[0].innerHTML.split('/');
                        patchString = patchOBBLocation[patchOBBLocation.length -1].toString();
                        document.getElementById("beforePatchObbName").innerHTML = patchString;
                        document.getElementById("IdmPatchObbName").innerHTML = patchString.slice(0, patchString.length-4) + ".zip";
                        document.getElementsByClassName("AfterMainObbName")[0].innerHTML = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementsByClassName("AfterMainObbName")[2].innerHTML = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementsByClassName("AfterPatchObbName")[0].innerHTML = XMdata.getElementsByTagName("patch_filename")[0].innerHTML;
                        document.getElementsByClassName("AfterPatchObbName")[1].innerHTML = XMdata.getElementsByTagName("patch_filename")[0].innerHTML;
                        document.getElementById("PackageName").innerHTML = array[array.length-4].toString();
                        document.getElementById("transferMain").style.display = "none";
                        document.getElementById("treviewPackageName").innerHTML = array[array.length-4].toString();
                        document.getElementById("treeviewMainObbName").innerHTML = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementById("treeviewPatchObbName").innerHTML = XMdata.getElementsByTagName("patch_filename")[0].innerHTML;
                        document.getElementById("secondTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Main OBB From Torrent" burnbit_file="' + XMdata.getElementsByTagName("main_path")[0].innerHTML + '" burnbit_style="normal"></a>';
                        document.getElementById("thirdTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Patch OBB From Torrent" burnbit_file="' + XMdata.getElementsByTagName("patch_path")[0].innerHTML + '" burnbit_style="normal"></a>';
                    } else if (XMdata.getElementsByTagName("main_path").length == 1) {
                        storeThirdLink = XMdata.getElementsByTagName("main_path")[0].innerHTML;
                        document.getElementById("mainObbLink").value = XMdata.getElementsByTagName("main_path")[0].innerHTML;
                        document.getElementById("downloadFourthRow").style.display = "none";
                        document.getElementById("optionThirdRow").style.display = "none";
                        document.getElementsByClassName('btn-flat waves-effect medium mdi-file-cloud-upload tooltipped')[1].href = XMdata.getElementsByTagName("main_path")[0].innerHTML;
                        document.getElementById("mainObbName").value = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementsByClassName("NoObbFileNotify")[0].style.display = "none";
                        document.getElementsByClassName("NoObbFileNotify")[1].style.display = "none";
                        document.getElementById("PatchDownloadSteps").style.display = "none";
                        mainOBBLocation = XMdata.getElementsByTagName("main_path")[0].innerHTML.split('/');
                        mainString = mainOBBLocation[mainOBBLocation.length - 1].toString();
                        document.getElementById("beforeMainObbName").innerHTML = mainString;
                        document.getElementById("IdmMainObbName").innerHTML = mainString.slice(0, mainString.length-4) + ".zip";
                        document.getElementsByClassName("AfterMainObbName")[0].innerHTML = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementsByClassName("AfterMainObbName")[1].innerHTML = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementById("PackageName").innerHTML = array[array.length-4].toString();
                        document.getElementById("transferPatch").style.display = "none";
                        document.getElementById("treviewPackageName").innerHTML = array[array.length-4].toString();
                        document.getElementById("treeviewMainObbName").innerHTML = XMdata.getElementsByTagName("main_filename")[0].innerHTML;
                        document.getElementById("LastTreeviewFile").style.display = "none";
                        document.getElementById("secondTorrentButtonDiv").innerHTML = '<a class="burnbit_torrent waves-effect tooltipped" data-position="top" data-delay="50" data-tooltip="Download Main OBB From Torrent" burnbit_file="' + XMdata.getElementsByTagName("main_path")[0].innerHTML + '" burnbit_style="normal"></a>';
                    } else {
                        document.getElementById("downloadThirdRow").style.display = "none";
                        document.getElementById("downloadFourthRow").style.display = "none";
                        document.getElementById("optionSecondRow").style.display = "none";
                        document.getElementById("optionThirdRow").style.display = "none";
                        document.getElementById("downloadObbOl").style.display = "none";
                        document.getElementById("installObbOl").style.display = "none";
                        document.getElementsByClassName("NoObbFileNotify")[0].style.display = "visible";
                        document.getElementsByClassName("NoObbFileNotify")[1].style.display = "visible";
                    }
                    document.getElementById("downloadSecondRow").style.display = "none";
                }
            }
        });
    }
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://sites.google.com/site/faizanrupani2013/xml/Aptoide.xml",
        onload: function(XmlReq) {
            if (XmlReq.statusText === "OK") {
                var XMLdata = XmlReq.responseXML;
                var changelogversion = XMLdata.getElementsByTagName('changelogversion');
                firstCheckVersion = changelogversion[0].getAttribute("versionName");
                for (i = 0; i < changelogversion.length; i++) {
                    document.getElementsByClassName('scriptOL')[0].innerHTML += '<br><li style="list-style-type: none;"><h4 class="md-title truncate" style="font-weight: 600 !important;margin-bottom: 5px;">Version v' + changelogversion[i].getAttribute("versionName") + '&emsp;' + changelogversion[i].getAttribute("changeDate") + '</h4><ul class="scriptlist" style="list-style-type:disc;margin-left: 50px;"></ul></li>';
                    var scriptlist = document.getElementsByClassName('scriptlist');
                    var changelogtext = changelogversion[i].getElementsByTagName('changelogtext');
                    for (var j = 0; j < changelogtext.length; j++) {
                        var listString = '<li style="list-style-type: inherit;">' + changelogtext[j].innerHTML + '</li>';
                        scriptlist[i].innerHTML += listString.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
                    }
                }
            }
        }
    });
     GM_xmlhttpRequest({
        method: "GET",
        url: "https://openuserjs.org/meta/FaizanAnwerAli/Aptoide_APK_and_OBB_Online_Downloader.meta.js",
        onload: function(q) {
            if (q.statusText === "OK") {
                secondCheckVersion = (((q.responseText).toString().split("\n"))[1].toString().split("    "))[1].toString();
            }
        }
    });
    GM_xmlhttpRequest({
        method: "GET",
        url: json.replace(/ /,'%2520'),
        onload: function(e) {
            if (e.statusText === "OK") {
                jsonText = e.responseText;
            } else {
                GM_xmlhttpRequest({
                    method: "GET",
                    url: json2.replace(/ /,'%2520'),
                    onload: function(ee) {
                        jsonText = ee.responseText;
                    }
                });
            }
        }
    });
    if(!isParsed) {
        for (var i = 0; i <= 3; i++) {
            var xmlUrl = "http://imgs.aptoide.com/apks/" + i + "/aptoide-f63c6f2461f65f32b6d144d6d2ff982e/" + storeName + "/" + resturl + ".myapp";
            textParsing(xmlUrl);
        }
    }
    function textParsing(xmlUrl){
        GM_xmlhttpRequest({
            method: "GET",
            url: xmlUrl,
            onload: function(xhr) {
                if (xhr.statusText === "OK") {
                    secondXmlText = xhr.responseText;
                    secondXmlLink = xmlUrl;
                }
            }
        });
    }
    angular.module('MyApp',['ngMaterial']).controller('SwitchDemoCtrl', function($scope, $mdDialog) {
        $scope.selectedIndex = 0;
        $scope.data = {
            cb1: true
        };
        $scope.showAdvanced = function(ev) {
            $mdDialog.show({
                controller: DialogController,
                templateUrl: 'dialog1.tmpl.html',
                parent: angular.element(document.body),
                targetEvent: ev
            });
        };
        function DialogController($scope, $mdDialog) {
            $scope.answer = function(answer) {
                $mdDialog.hide(answer);
            };
        }
    });
    $(document).on('ready', function(){
        $('.tooltipped').tooltip({
            delay: 50
        });
        $('#browser').treeview();
        $('.collapsible').collapsible({
            accordion: true
        });
        $('.modal-trigger').leanModal({
            dismissible: true,
            opacity: 0.5,
            in_duration: 300,
            out_duration: 200,
            ready: function() {
                $('.burnbit_button_text').text('Torrent');
            },
            complete: function() {
                Materialize.toast('Material Design Modal Closed', 2000);
            }
        });
    });
    $(window).load(function() {
        document.getElementById("apkName").value = array[array.length-4].toString() + ".apk";
        document.documentElement.spellcheck = false;
        $('#closemodelcrosssign').on('click', function(){
            $('#modal1').closeModal();
            Materialize.toast('Material Design Option Model Closed!', 2000);
        });
        function firstCopy(){
            if (storeFirstLink === "" || document.getElementById("apkLink").value === "[Empty]") {
                Materialize.toast('Apk Link is not Available', 2000);
            } else {
                GM_setClipboard(storeFirstLink);
                Materialize.toast('APK Link Copied to Clipboard', 2000);
            }
        }
        shortcut.add("Shift+Alt+D", firstCopy);
        $('#firstCopy').on('click', firstCopy);
        function secondCopy(){
            if (storeSecondLink === "" || document.getElementById("alternativeLink").value === "[Empty]") {
                Materialize.toast('Alternative APK Link is not Available', 2000);
            } else {
                GM_setClipboard(storeSecondLink);
                Materialize.toast('Alternative APK Link Copied to Clipboard', 2000);
            }
        }
        shortcut.add("Shift+Alt+A", secondCopy);
        $('#secondCopy').on('click', secondCopy);
        function thirdCopy(){
            if (storeThirdLink === "" || document.getElementById("mainObbLink").value === "[Empty]") {
                Materialize.toast('Main OBB Link is not Available', 2000);
            } else {
                GM_setClipboard(storeThirdLink);
                Materialize.toast('Main OBB Link Copied to Clipboard', 2000);
            }
        }
        shortcut.add("Shift+Alt+M", thirdCopy);
        $('#thirdCopy').on('click', thirdCopy);
        function fourthCopy(){
            if (storeFourthLink === "" || document.getElementById("patchObbLink").value === "[Empty]") {
                Materialize.toast('Patch OBB Link is not Available', 2000);
            } else {
                GM_setClipboard(storeFourthLink);
                Materialize.toast('Patch OBB Link Copied to Cliboard', 2000);
            }
        }
        shortcut.add("Shift+Alt+P", fourthCopy);
        $('#fourthCopy').on('click', fourthCopy);
        function firstDownload() {
            if (storeFirstLink === "" || document.getElementById("apkLink").value === "[Empty]") {
                Materialize.toast('Apk Link is not Available', 2000);
            } else {
                Materialize.toast('Downloading APK', 2000);
                window.location = storeFirstLink;
            }
        }
        shortcut.add("Shift+D", firstDownload);
        $('#firstDownload').on('click', firstDownload);
        function secondDownload(){
            if (storeSecondLink === "" || document.getElementById("alternativeLink").value === "[Empty]") {
                Materialize.toast('Alternative APK Link is not Available', 2000);
            } else {
                Materialize.toast('Downloading Alternative Link APK', 2000);
                window.location = storeSecondLink;
            }
        }
        shortcut.add("Shift+A", secondDownload);
        $('#secondDownload').on('click', secondDownload);
        function thirdDownload(){
            if (storeThirdLink === "" || document.getElementById("mainObbLink").value === "[Empty]") {
                Materialize.toast('Main OBB Link is not Available', 2000);
            } else {
                Materialize.toast('Downloading Main OBB File', 2000);
                window.location = storeThirdLink;
            }
        }
        shortcut.add("Shift+M", thirdDownload);
        $('#thirdDownload').on('click', thirdDownload);
        function fourthDownload(){
            if (storeFourthLink === "" || document.getElementById("patchObbLink").value === "[Empty]") {
                Materialize.toast('Patch OBB Link is not Available', 2000);
            } else {
                Materialize.toast('Downloading Patch OBB File', 2000);
                window.location = storeFourthLink;
            }
        }
        shortcut.add("Shift+P", fourthDownload);
        $('#fourthDownload').on('click', fourthDownload);
        $('#downloadApkToPC').on('click', function(){
            Materialize.toast('Downloading APK', 2000);
            var directApkUrl = "http://pool.apk.aptoide.com/" + storeName + "/" + resturl + "-" + md5 + ".apk";
            window.location = directApkUrl;
        });
        function downloadFirstXML(){
            Materialize.toast('Downloading First XML File', 2000);
            download(vkbeautify.xml(firstXmlText), array[array.length-4].toString() + "_v" + appVer + "_build_" + array[array.length-3].toString() + "_First_XML_File" + ".xml", "text/xml");
        }
        shortcut.add("Shift+1", downloadFirstXML,{'type':'keydown','propagate':true,'target':document});
        $('#downloadFirstXML').on('click', downloadFirstXML);
        function downloadSecondXML(){
            Materialize.toast('Downloading Second XML File', 2000);
            download(vkbeautify.xml(secondXmlText), array[array.length-4].toString() + "_v" + appVer + "_build_" + array[array.length-3].toString() + "_Second_XML_File" + ".xml", "text/xml");
        }
        shortcut.add("Shift+2", downloadSecondXML);
        $('#downloadSecondXML').on('click', downloadSecondXML);
        function downloadJson(){
            Materialize.toast('Downloading JSON File', 2000);
            download(vkbeautify.json(jsonText, 4 ), array[array.length-4].toString() + "_v" + appVer + "_build_" + array[array.length-3].toString() + "_JSON_File" + ".json", "text/json");
        }
        shortcut.add("Shift+3", downloadJson);
        $('#downloadJson').on('click', downloadJson);
        shortcut.add("Shift+4", function() {
            GM_setClipboard(xml);
            Materialize.toast('First XML Link Copied to Cliboard', 2000);
        });
        shortcut.add("Shift+5", function() {
            GM_setClipboard(secondXmlLink);
            Materialize.toast('Second XML Link Copied to Cliboard', 2000);
        });
        shortcut.add("Shift+6", function() {
            GM_setClipboard(json);
            Materialize.toast('JSON Link Copied to Cliboard', 2000);
        });
        shortcut.add("Shift+7", function() {
            GM_openInTab(xml.replace(/ /,'%2520'), false);
        });
        shortcut.add("Shift+8", function() {
            GM_openInTab(xml2.replace(/ /,'%2520'), false);
        });
        shortcut.add("Shift+9", function() {
            GM_openInTab(json.replace(/ /,'%2520'), false);
        });
        shortcut.add("Shift+0", function() {
            GM_openInTab(json2.replace(/ /,'%2520'), false);
        });
        shortcut.add("Shift+O", function() {
            $('#modal1').openModal({
                dismissible: true,
                opacity: 0.5,
                in_duration: 300,
                out_duration: 200,
                ready: function() {
                    $('.burnbit_button_text').text('Torrent');
                },
                complete: function() {
                    Materialize.toast('Material Design Modal Closed', 2000);
                }
            });
        });
        function Reset(){
            GM_setValue("getTotalSecond", 0);
            GM_setValue("runTimeCheck", 1);
            GM_setValue("getScriptTotalSecond", 0);
            Materialize.toast('Refresh Page to See Changes', 2000);
        }
        shortcut.add("Shift+R", Reset);
        $('#resetTiming').on('click', Reset);
        if (firstCheckVersion !== currentVersion ) {
            updateCheck(firstCheckVersion);
        } else if (secondCheckVersion !== currentVersion ) {
            updateCheck(secondCheckVersion);
        } else {
            document.getElementById("needUpdateButton").style.display = "none";
            document.getElementById("needUpdateUL").style.display = "none";
            document.getElementById("updatedUL").innerHTML = '<li style="list-style-type: inherit;">You\'re using latest Version v' + currentVersion + '.</li>';
        }
        function updateCheck(checkVersion){
            document.getElementById("updateNotificationText").innerHTML = "You're using v" + currentVersion + ".<br>A new version v" + checkVersion + " is available for update.";
            document.getElementById("needUpdateUL").innerHTML = '<li style="list-style-type: inherit;">You\'re using v' + currentVersion + '.</li><li style="list-style-type: inherit;">A new version v' + checkVersion + ' is available.</li>';
            document.getElementById("updatedUL").style.display = "none";
            $('#modal2').openModal();
        }
        var endTime = (new Date()).getTime();
        var millisecondsLoadingDocumentStart = endTime - startTime, millisecondsLoadingDocumentEnd = endTime - scriptStartTime;
        function millisToMinutesAndSeconds(millis) {
            var seconds = ((millis % 60000) / 1000).toFixed(3);
            return seconds;
        }
        var firstTimeReturn = millisToMinutesAndSeconds(millisecondsLoadingDocumentStart);
        var secondTimeReturn = millisToMinutesAndSeconds(millisecondsLoadingDocumentEnd);
        var getsec = parseFloat(secondTimeReturn), getScriptsec = parseFloat(firstTimeReturn);
        if (runTimeCheck == 1) {
            TotalSec = getsec;
            TotalScriptSec = getScriptsec;
            document.getElementById("fifthTime").innerHTML = "You've visited First time since installation. Thank you.";
        } else {
            TotalSec = getTotalSecond + getsec;
            TotalScriptSec = getScriptTotalSecond + getScriptsec;
            document.getElementById("fifthTime").innerHTML = "You've visited " + runTimeCheck + " times since installation.";
        }
        var avgResult = parseFloat(TotalSec) / runTimeCheck, scriptAvgResult = parseFloat(TotalScriptSec) / runTimeCheck;
        GM_setValue("getTotalSecond", parseFloat(TotalSec));
        GM_setValue("runTimeCheck", parseFloat(runTimeCheck + 1));
        GM_setValue("getScriptTotalSecond", parseFloat(TotalScriptSec));
        document.getElementById("firstTime").innerHTML = "Script loading time is " + secondTimeReturn + " sec.";
        document.getElementById("secondTime").innerHTML = "Website + Script loading time is " + firstTimeReturn + " sec.";
        document.getElementById("thirdTime").innerHTML = "Average Script loading timing is " + parseFloat(avgResult).toFixed(3) + " sec.";
        document.getElementById("fourthTime").innerHTML = "Average Website + Script loading timing is " + parseFloat(scriptAvgResult).toFixed(3) + " sec.";
        document.getElementById("optionModel").style.visibility = "visible";
        document.getElementById("downloadApkToPC").style.visibility = "visible";
    });
}