之前写过一篇文章:获取AppStore上架后的应用版本号,那一篇文章使用node.js实现,存在的问题就是如果在没有安装node.js运行环境下是无法运行的,而且该程序依赖request模块,为了方便其它人也能使用,想到把它做成一个本地应用程序。然后想了一下,觉得最简单的就是使用hta文件(它的Ajax请求可跨域^_^)。

因为我们手游产品已经有三款了,所以“应用地址”那一栏,我使用了下拉框,其它组的成员只需要点击选中需要检测的应用,然后点击“检测版本”按钮,程序将开始运行。当匹配到版本为最新的版本时,登录OA系统,向需要获取版本更新信息的人员发送OA提醒。

原理比较简单,代码也并不复杂。将源码本地另存为.hta后缀的文件,然后双击它就可以运行了。

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>检测App最新版本号</title><hta:application id="fetchFIle" applicationname="fetchFIle" singleinstance="yes" border="thin" scroll="no" maximizeButton="no"><style type='text/css'>h3 {border-left:3px solid 666; color:#666; text-indent:10px; margin:15px 0;}textarea {border:2px solid #888; background-color:#222; font-family:'Courier New'; font-size:14px; color:#3c0;}a {color:#657528;}a:hover {background:#c8dc7b;}

.exec-btn {border:1px solid #666; background-color:#9c0; color:#360; padding:5px 5px 3px 5px; margin-left:10px; width:70px; height:30px; vertical-align:middle; cursor:pointer; display:inline-block;}

body {background-color:#eee; margin:0; padding:0; overflow:hidden; text-align:center;}

#wrapper {width:800px; margin:30px auto; padding:30px; border:1px solid #ccc; text-align:left;}.ipt {width:600px; height:25px; line-height:22px; vertical-align:middle; padding:0 2px;}</style></head><body><div id="wrapper">    <p>  应用的地址:<select id='ipt_url'>        <option value="">【请选择一款应用】</option>        <option value="https://itunes.apple.com/cn/app/huang-di-jue-qi/id604615270?mt=8">【皇帝崛起】</option>        <option value="https://itunes.apple.com/cn/app/feng-liu-tian-zi/id670188672?mt=8">【风流天子】</option>        <option value="https://itunes.apple.com/cn/app/gong-ting-feng-yunhd/id543140000?mt=8">【宫廷风云】</option>    </select></p>    <p>应用的最新版本:<input type='text' class='ipt' value="1.0.2" style="width:100px;" id="ipt_ver"/></p>    <p> 轮询间隔时长:<input type='text' class='ipt' value='3' style='width:100px;' id='ipt_duration'/>秒</p>    <p>需要通知的人员:<textarea style='width:600px; height:140px;' id="ipt_uids">zhangyi</textarea></p>    <p style='padding-left:118px;'><button class='exec-btn' οnclick="startCheck()" id='btn_check'>检测版本</button><span style='padding-left:350px;color:#666;'>多人请使用回车进行分隔</span></p></div>

<div style='border:1px solid #ccc; width:800px; margin:30px auto; text-align:left; padding:10px;'>    <p>应用名称:<span id='app_name'></span></p>    <p>当前版本:<span id='curr_ver'></span></p></div>

<div style='position:absolute; bottom:10px; right:30px;'>&copy;版本所有:<a href="http://www.cnblogs.com/meteoric_cry" target='_blank'>Meteoric_cry</a></div>

<script type="text/javascript">String.prototype.trim = function(r){return this.replace(r || /(^\s+)|(\s+$)/g, "");}

function getEl(id) {return typeof id == 'string' ? document.getElementById(id) : id;}

var FWKAjax = function () {return {        getXHR: function () {            var e = null;try {return (e = new XMLHttpRequest());            } catch (d) {for (var c = 0, b = ["MSXML3", "MSXML2", "Microsoft"]; c < b.length; c++) {try {                        e = new ActiveXObject(b[c] + ".XMLHTTP");break;                    } catch (d) {}                }            }return e;        },        request: function (b, c) {            var d = this.getXHR();if (!d) {throw new Error("cant't initialize xhr instance.");            }            var a = {};            a.method = (c.method || "get").toUpperCase();            a.asyn = true;            a.onSuccess = c.onSuccess || function () {};            a.onFailure = c.onFailure || function () {};            a.postData = c.postData || null;            d.open(a.method, b, a.asyn);

if ("POST" == a.method) {                d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");            } else {                d.setRequestHeader('If-Modified-Since', new Date(0).toGMTString());                d.setRequestHeader('Cache-Control', 'no-cache');            }

            d.onreadystatechange = function () {if (d.readyState == 4) {if (d.status == 0 || d.status == 200) {                        a.onSuccess(d);                    } else {                        a.onFailure(d);                    }

                    d = null;                    a = null;                }            };

            d.send(a.postData);        }    };}();

function startCheck() {    var url = getEl('ipt_url').value.trim()    var ver = getEl('ipt_ver').value.trim()

if (!url) {        alert('请选择要检测的应用');        getEl('ipt_url').focus();return false;    }

if (!ver) {        alert('请输入要检测的应用版本号');return false;    }

    var duration = getEl('ipt_duration').value * 1000 || 3 * 1000;    var uids = getEl('ipt_uids').value.trim().replace(/\r\n/g, ',');

if (!uids) {        alert("请输入要通知的人员名单列表");return ;    }

    var btnElem = getEl('btn_check');    btnElem.setAttribute("disabled", "disabled");    btnElem.innerHTML = "正在检测";

    checkHandler(url, ver, duration, uids)}

function checkHandler(url, ver, duration, uids) {    FWKAjax.request(url + "&t=" + new Date().getTime(), {'method' : 'get','onSuccess' : ajaxCallback,'onFailure' : ajaxCallback,'postData' : null    });

function ajaxCallback(xhr) {        var htmlContent = xhr.responseText;        xhr = null;

if (/<h1>([^<]+)<\/h1>/.test(htmlContent)) {            var appName = RegExp["$1"];            getEl('app_name').innerHTML = appName;        }

if (/\<li\><span class=\"label\">版本\: <\/span>([^<]+)\<\/li\>/.test(htmlContent)) {            var currVer = RegExp["$1"];

            getEl('curr_ver').innerHTML = currVer;

            var appDomainName = url.split('/app/')[1].split('/')[0];

            if (currVer == ver) {                sendOA_Notification(appDomainName, currVer, uids);                return ;            }        }

        setTimeout(function() {            checkHandler(url, ver, duration, uids)        }, duration);    }}

function sendOA_Notification(appName, currVer, uids) {    FWKAjax.request("http://oa.xx.net/logincheck.php?UNAME=xx1&PASSWORD=xx2", {'method' : 'GET','onSuccess' : function(xhr) {if (/location=\"general\"\;/.test(xhr.responseText)) {                sendMsg(appName, currVer, uids);            }         },        'onFailure' : null,        'postData' : null    });}

function sendMsg(appName, currVer, uids) {

    var data_str = "uid=" + uids + "&cont=[" + appName + "] AppStore Latest Version:" + currVer;

    FWKAjax.request("http://oa.xx.net/general/reservation/sendsmsapi.php", {'method' : 'post','onSuccess' : function(xhr) {            alert("版本更新提醒已发送!");

            var btnElem = getEl('btn_check');            btnElem.removeAttribute("disabled");            btnElem.innerHTML = "检测版本";         },'onFailure' : null,'postData' : data_str    });}

!(function() {    var winsize = {        winwidth: 900,        winheight: 650,        scrnwidth: screen.availWidth,        scrnheight: screen.availHeight    };

    window.resizeTo(winsize.winwidth, winsize.winheight);})();

window.οnerrοr=function(a,b,c){    alert("检测脚本发生了以下异常:"+a+"\n所在行:"+c);return true;}

</script>

</body></html>

转载于:https://www.cnblogs.com/meteoric_cry/p/3311125.html

【hta版】获取AppStore上架后的应用版本号相关推荐

  1. 获取AppStore上架后的应用版本号

    应用通过审核以后,由开发者设置应用上架,但何时能在appstore搜索到该应用,这个时间不等,有时候15分钟左右有时候2个多小时,以前就是隔一段时间打开网页然后刷新一下,或者搜索一下,查看版本号,操作 ...

  2. forum.php 重定向,解析php 版获取重定向后的地址(代码)

    本篇文章是对php版获取重定向后的地址实现代码进行了详细的分析介绍,需要的朋友参考下 //取重定向的地址 class RedirectUrl{ //地址 var $url; //初始化地址 funct ...

  3. h5+app Android上架华为应用市场被拒原因“拒绝获取手机权限后app会闪退“以及隐私政策问题

    h5+app Android上架华为应用市场被拒原因"拒绝获取手机权限后app会闪退" 华为应用市场报错:拒绝获取手机权限后app会闪退,此问题解决方案如下: 在manifest. ...

  4. 文心一言App在苹果AppStore上架;首款搭载ChatGPT的自行车问世;QQ Windows全新上架|极客头条

    「极客头条」-- 技术人员的新闻圈! CSDN 的读者朋友们早上好哇,「极客头条」来啦,快来看今天都有哪些值得我们技术人关注的重要新闻吧. 整理 | 梦依丹 出品 | CSDN(ID:CSDNnews ...

  5. java获取页面标签_java获取网页源代码后,提取标签内容……

    java获取网页源代码后,提取标签内容-- 关注:245  答案:2  mip版 解决时间 2021-02-01 09:11 提问者咏bù琂败 2021-01-31 13:49 import java ...

  6. IT连创业系列:说说苹果商店AppStore上架App应用前后遇到的那些神坑

    前言: IT连创业的这个系列,又隔空了一个多月了. 不知道为什么,最近写文的冲动感下降了很多,如果不是因为特别忙,大概就因为上了年纪的原因了. 群里关注我创业的朋友,一直都在问,啥时候有新的文章讲述创 ...

  7. 红米4鸿蒙系统刷机包,小米 红米4 高配版获取Root权限服务含精简系统方案

    安卓手机一旦获取Root权限就好像拥有了全世界 独家系统精简方案,优化系统流畅度,还你如初的感受. 刷前须知: 使用本服务前,请保证手机未进行刷机或root权限 使用本服务不会清除手机数据,但建议备份 ...

  8. Matlab Mobile手机版获取gps数据和加速度信号融合

    Matlab Mobile手机版获取gps数据和加速度信号融合 前言 安装matlab mobile Matlab Drive Connector 安装 Matlab Mobile 记录数据 Matl ...

  9. getPrepayId php,获取到 prepay_id 后将参数再次签名传输给 APP 发起支付

    获取到 prepay_id 后将参数再次签名传输给 APP 发起支付. 相信有不少同学因为看到统一下单返回的结果中有 sign 字段,会直接将结果返回给 APP 端,结果 APP 端没办法调起微支付. ...

最新文章

  1. php中query()作用,query()方法
  2. 【AngularJS】—— 4 表达式
  3. leetcode算法题--飞机座位分配概率
  4. 且看微软的.Net和Sun公司的J2EE如何对垒
  5. C# 线程手册 第五章 扩展多线程应用程序 系列
  6. java ftp上传文件 linux_Java实现把文件上传至ftp服务器
  7. Regarding @Inject annotation
  8. 使用Spring Integration进行消息处理
  9. 将Java 8支持添加到Eclipse Kepler
  10. std string与线程安全_C++标准库多线程简介Part1
  11. python向量化和c哪个快_在python中向量化6 for循环累积和
  12. android 手动回收对象,Android Studio Studio回收列表中的JSON对象
  13. JDK源码解析之 Java.lang.Float
  14. Java—static关键字
  15. 专访 | 「Smartbi 」VP徐晶:未来,BI将成为决策者的诸葛亮
  16. Vue角色的权限管理
  17. java编写万年历_怎么用JAVA编写万年历!
  18. cher怎么翻译中文_中文翻译法语收费标准是怎么定的
  19. Java调用第三方http接口的常用方式
  20. 从应用层设置mx31-pdk板的lcd背光亮度

热门文章

  1. LibreOJ #6002. 「网络流 24 题」最小路径覆盖
  2. CSS 实现三角形、梯形、等腰梯形
  3. 浅谈C++的virtual 动态绑定。
  4. struts的国际化
  5. [上海]LinkCoder第四期活动——Jeffrey Richter:Win 8应用开发与.NET4.5
  6. HDU1272_并查集
  7. 可以在Silverlight中使用的,支持定时自动回收的缓存类(C# 代码)
  8. PMCAFF《产品经理第一课》第三期开始报名!天团导师再次升级,631培训模式升级...
  9. 讨论下 Java 流文件读写缓存大小设置的问题
  10. 微信环境中如何实现下载apk文件的下载