王者荣耀优化开启[ROOT]

var filePref = "/data/data/com.tencent.tmgp.sgame/shared_prefs/com.tencent.tmgp.sgame.v2.playerprefs.xml";
var modifies = {
"EnableMTR" : "1",
"EnableGLES3" : "3",
"EnableVulkan" : "3"
};

var choose =
dialogs.select("Enable Multi-threading Render?[yes]", ["yes", "no"]);
modifies.EnableMTR = choose < 0 ? 1 : ([1, 0])[choose];

choose =
dialogs.select("Select Render Backend:[OpenGL ES2.0]",
["OpenGL ES2.0", "OpenGL ES3.0", "Vulkan"]);

log(choose);
if (choose == 1){
modifies.EnableGLES3 = "2";
}
else if (choose == 2){
modifies.EnableVulkan = "2";
}

log("Gaining root access...");
var readProc = java.lang.Runtime.getRuntime().exec("su");
var conStream = new java.io.DataOutputStream(
readProc.getOutputStream());
var inputStream = new java.io.DataInputStream(
readProc.getInputStream());

conStream.writeBytes("cat " + filePref + "\n");
conStream.flush();
conStream.close();

var writeProc = java.lang.Runtime.getRuntime().exec("su");
var outputStream = new java.io.DataOutputStream(
writeProc.getOutputStream());

log("Creating temporary property file...");

outputStream.writeBytes("cat > " + filePref + ".tmp" + "\n");
outputStream.flush();

importPackage(org.xml.sax);
importPackage(org.xml.sax.helpers);
importPackage(javax.xml.parsers);
importPackage(org.xmlpull.v1);
importPackage(java.io);

var map = {};
var currentString;

var prefHandler = JavaAdapter(DefaultHandler, {
startElement: function(namespace, name, qname, attrs) {
if (name == "map"){return;}

    var kv = {};
    
    var len = attrs.getLength();
    for (var i=0; i < len; i ++){
        var aname = attrs.getLocalName(i),
            aval  = attrs.getValue(i);
        kv[aname] = aval;
    }
    
    if (name != "string"){
        map[kv.name] = [name, kv.value];
    }
    else{
        currentString = kv.name;
    }
},
characters: function(ch, start, len){
    if (currentString){
        map[currentString]
            = ["string", new java.lang.String(ch, start, len)];
        currentString = undefined;
    }
},

});

var parserFactory = SAXParserFactory.newInstance();
var parser = parserFactory.newSAXParser();

log("Reading XML property...");
parser.parse(inputStream, prefHandler);

for (key in modifies){
map[key][1] = modifies[key];
}

var outputWriter
= new BufferedWriter(new OutputStreamWriter(outputStream));
var Xmlfactory = XmlPullParserFactory.newInstance();
var serializer = Xmlfactory.newSerializer();
serializer.setOutput(outputWriter);

serializer.startDocument("UTF-8", true);
serializer.startTag("", "map");
for(var key in map){
if (map[key][0] == "string"){
serializer.startTag("", "string");
serializer.attribute("", "name", key);
serializer.text(map[key][1].trim());
serializer.endTag("", "string");
}
else {
serializer.startTag("", map[key][0]);
serializer.attribute("", "name", key);
serializer.attribute("", "value", map[key][1]);
serializer.endTag("", map[key][0]);
}
}
serializer.endTag("", "map");
serializer.endDocument();

var copyProc = java.lang.Runtime.getRuntime().exec("su");
var copyStream = new java.io.DataOutputStream(
copyProc.getOutputStream());

log("Writing back...");
copyStream.writeBytes("cp " + filePref + ".tmp " + filePref + "\n");
copyStream.flush();
copyStream.close();

outputStream.close();
inputStream.close();

log("Launching Sgame...");
launch("com.tencent.tmgp.sgame");
java.lang.System.exit(0);

这个脚本能够切换王者荣耀的渲染后端及开启多线程优化,root是必需的

管理员

six six six

  • 3
    帖子
  • 2215
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待