// ==UserScript== // @name JScript测试 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://bbs.tampermonkey.net.cn/thread-3453-1-1.html // @icon https://bbs.tampermonkey.net.cn/favicon.ico // @grant none // ==/UserScript== "use strict"; // 这里可以放一个视频教程,或者收费服务(`・ω・´) var url = "https://bbs.tampermonkey.net.cn/thread-3453-1-1.html"; // 啊没错,这也是本代码的来源 // 理论上可以做很多事情的,比如format(不是)。。。咳咳需要权限 // 反正可以运行shell就很离谱,完全可以调用cmd然后自动提权然后format(不是。。。怎么跟format绑定关系了。。。) // 还可以通过调用【wmic os get buildnumber,Caption /value】获取系统版本号啊什么的 // 不过估计有可能会报毒。。。 if (typeof WScript==="object") {//推荐这么写吧,注释法打包的时候如果把注释给删了容易暴毙 var shell = WScript.CreateObject("WScript.Shell"); var hasChrome = false; // 通过注册表判断是否安装chrome // 绿色版什么的不谈。。。 // 其实可以直接用start 通过系统默认打开方式打开。。。 // 注册表信息来自https://stackoverflow.com/questions/50880917 var exec = shell.Exec( 'reg query "HKEY_CURRENT_USER\\Software\\Google\\Chrome\\BLBeacon" /v version' ); // 获取shell返回数据理论来自 https://stackoverflow.com/questions/6060876 改了亿点点 // 等待异步执行 while (exec.Status == 0) { WScript.Sleep(50); } var output = null; //判断是否执行成功(跟cmd那个返回值差不多) if (exec.ExitCode == 1) { //失败了,估计没有 output = exec.StdErr.ReadAll(); } else { //这里是成功获取到了 output = exec.StdOut.ReadAll(); hasChrome = true; } // WScript.echo(output); // chrome版本或者“不存在键值巴拉巴拉” // 相关说明 https://www.vbsedit.com/html/f482c739-3cf9-4139-a6af-3bde299b8009.asp var isok = shell.Popup( "\u811A\u672C\u9700\u8981\u4F7F\u7528\u5B89\u88C5\u811A\u672C\u732B\u7684\u73B0\u4EE3\u6D4F\u89C8\u5668\u6253\u5F00\uFF0C\n" .concat( hasChrome ? "" : "\u672A", "\u68C0\u6D4B\u5230Chrome\u6D4F\u89C8\u5668\uFF0C\n\u70B9\u51FB\u3010Yes\u3011\u5728" ) .concat( hasChrome ? "Chrome" : "edge", "\u6D4F\u89C8\u5668\u91CC\u6253\u5F00\u64CD\u4F5C\u8BF4\u660E\uFF0C\n" ) .concat( hasChrome ? "\u70B9\u51FB\u3010no\u3011\u5728edge\u6D4F\u89C8\u5668\u91CC\u6253\u5F00\u64CD\u4F5C\u8BF4\u660E\uFF0C" : "", "\n\u5176\u4ED6\u6309\u94AE\u6216\u800510\u79D2\u540E\u53D6\u6D88\u6253\u5F00\u8BF4\u660E\u64CD\u4F5C\u3002\n\uFF0810\u79D2\u540E\u81EA\u52A8\u53D6\u6D88\uFF09" ), 10, "\u53CB\u60C5\u63D0\u9192", (hasChrome ? 3 : 4) + 48 ); if (isok === 6) { //Yes if (hasChrome) shell.Run("chrome.exe " + url); else shell.Run("msedge " + url); } else if (isok === 7 && hasChrome) { //No shell.Run("msedge " + url); } else { WScript.echo("\u90A3\u4F60\u5230\u5E95\u60F3\u5E72\u561B\uFF1F"); } WScript.quit(); } else { console.log("\u4e0b\u9762\u8be5\u5e72\u5565\u5e72\u5565\uff0c"); console.log("\u4f46\u662f\u4e5f\u9700\u8981unicode\u7f16\u7801\uff0c"); console.log("\u8fd8\u9700\u8981\u68a6\u56de\u5317\u4eac\u5965\u8fd0"); }