// ==UserScript== // @name Xbox CLoud Gaming优化整合 // @name:zh-CN Xbox CLoud Gaming优化整合 // @namespace http://tampermonkey.net/xbox/nft // @version 1.0.5 // @description:zh-cn 整合和修改现有脚本,感谢@TGSAN,@刘翠两位大佬,该脚本支持ios,pc,安卓,★★★注意!【Pc和安卓修改语言在插件选项里开启】,优化项:ios语言中文繁体选择+免代理直连+safari免添加桌面+禁用低画质+隐藏滚动条+裸连网络中强制开启触屏控制+美化打开basic触控方式后的左上角basic悬浮按钮的样式。 【xbox云游戏交流群531602832】 // @author 奈非天 // @match https://www.xbox.com/*/play* // @run-at document-start // @grant unsafeWindow // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_setValue // @grant GM_getValue // @original-script https://greasyfork.org/zh-CN/scripts/455741-xbox-cloud-gaming%E4%BC%98%E5%8C%96%E6%95%B4%E5%90%88 // @description 整合和修改现有脚本,感谢@TGSAN,@刘翠两位大佬,该脚本支持ios,pc,安卓,★★★注意!【Pc和安卓修改语言在插件选项里开启】,优化项:ios语言中文繁体选择+免代理直连+safari免添加桌面+禁用低画质+隐藏滚动条+裸连网络中强制开启触屏控制+美化打开basic触控方式后的左上角basic悬浮按钮的样式。 【xbox云游戏交流群531602832】 // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... const originFetch = fetch; var isSptGM=false; try{ GM_getValue('abcdegf') isSptGM=true; }catch(e){ } var xcloud_game_language; var canVibrating=0; //添加菜单 if(isSptGM){ //语言 function set_language(){ switch(game_language) { case 1: xcloud_game_language = 2; break; case 2: xcloud_game_language = 1; break; default: xcloud_game_language = 1; } GM_setValue("xcloud_game_language", xcloud_game_language); GM_unregisterMenuCommand(menuid_game_language); menuid_game_language = GM_registerMenuCommand(xcloud_game_language === 1 ? "默认语言:简体" : "默认语言:繁体", set_language, "l"); alert("语言已设置为:"+(xcloud_game_language === 1 ? "【简体】" : "【繁体】")) } xcloud_game_language = GM_getValue("xcloud_game_language",1); var menuid_game_language = GM_registerMenuCommand(xcloud_game_language === 1 ? "当前语言:简体" : "当前语言:繁体", set_language, "l"); } let windowCtx = self.window; if (self.unsafeWindow) { console.log("使用unsafeWindow模式"); windowCtx = self.unsafeWindow; } else { console.log("使用原生模式"); } function HookProperty(object, property, value) { Object.defineProperty(object, property, { value: value }); } let fakeuad = { "brands": [ { "brand": "Microsoft Edge", "version": "999" }, { "brand": "Chromium", "version": "999" }, { "brand": "Not=A?Brand", "version": "24" } ], "mobile": false, "platform": "Windows" }; try{ HookProperty(windowCtx.navigator, "userAgent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/999.0.0.0 Safari/537.36 Edg/999.0.0.0"); HookProperty(windowCtx.navigator, "appVersion", "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/999.0.0.0 Safari/537.36 Edg/999.0.0.0"); HookProperty(windowCtx.navigator, "platform", "Win32"); HookProperty(windowCtx.navigator, "appName", "Netscape"); HookProperty(windowCtx.navigator, "appCodeName", "Mozilla"); HookProperty(windowCtx.navigator, "product", "Gecko"); HookProperty(windowCtx.navigator, "vendor", "Google Inc."); HookProperty(windowCtx.navigator, "vendorSub", ""); HookProperty(windowCtx.navigator, "maxTouchPoints", undefined); HookProperty(windowCtx.navigator, "userAgentData", fakeuad); HookProperty(windowCtx.navigator, "connection", undefined); HookProperty(windowCtx.navigator, "standalone", true); }catch(e){} windowCtx.fetch = (...arg) => { //fetch = (...arg) => { // console.log('fetch arg', ...arg); let arg0 = arg[0]; let url = ""; let isRequest = false; switch (typeof arg0) { case "object": url = arg0.url; isRequest = true; break; case "string": url = arg0; break; default: break; } if (url.indexOf('xgpuweb.gssv-play-prod.xboxlive.com/v2/login/user') > -1){ console.log('xff欺骗开始'+url) return new Promise((resolve, reject) => { if (isRequest && arg0.method == "POST") { arg0.json().then(json => { let body = JSON.stringify(json); arg[0].headers.set('x-forwarded-for','168.126.63.1') arg[0] = new Request(url, { method: arg0.method, headers: arg0.headers, body: body, }); originFetch(...arg).then(res => { console.log('xff欺骗结束') resolve(res); }).catch(err => { reject(err); }); }); } else { console.error("[ERROR] Not a request."); return originFetch(...arg); } }); }else if (url.indexOf('/v5/sessions/cloud/play') > -1) { console.log('语言开始') document.documentElement.style.overflowY = "hidden" // Start Configuration return new Promise((resolve, reject) => { if (isRequest && arg0.method == "POST") { arg0.json().then(json => { let selectedLanguage=''; if(isSptGM){ selectedLanguage=xcloud_game_language===1?'zh-CN':"zh-TW" }else{ var yuyan = confirm("确定是简体,取消是繁体"); if(yuyan){ selectedLanguage="zh-CN" }else{ selectedLanguage="zh-TW" } } json["settings"]["locale"] = selectedLanguage; let body = JSON.stringify(json); arg[0] = new Request(url, { method: arg0.method, headers: arg0.headers, body: body, mode: arg0.mode, credentials: arg0.credentials, cache: arg0.cache, redirect: arg0.redirect, referrer: arg0.referrer, integrity: arg0.integrity }); originFetch(...arg).then(res => { console.log('语言结束') resolve(res); let cssChanged= setInterval(function(){ let basicBtn=$('.EditErgoMenu-module__basicControlsButtonColor___1sLIY'); if(basicBtn!=null){ if(basicBtn.css('color')!='black'){ $('.EditErgoMenu-module__basicControlsButtonColor___1sLIY').text('X') //$('.EditErgoMenu-module__basicControlsButtonColor___1sLIY').css('color',' black') $('.EditErgoMenu-module__basicControlsButtonColor___1sLIY').css('width',' 10px') $('.EditErgoMenu-module__basicControlsButtonColor___1sLIY').css('min-width',' 10px') $('.EditErgoMenu-module__basicControlsButtonColor___1sLIY').css('background-color','rgba(255,0,0,0)') $('.EditErgoMenu-module__basicControlsButtonColor___1sLIY').css('opacity','0.3') } } },2000) }).catch(err => { reject(err); }); }); } else { console.error("[ERROR] Not a request."); return originFetch(...arg); } }); } else if (url.indexOf('/v2/login/user') > -1 && url.indexOf('xgpuweb.gssv-play-prod.xboxlive.com')<0) { console.log('允许修改区域开始') return new Promise((resolve, reject) => { originFetch(...arg).then(res => { res.json().then(json => { // console.error(json); json["offeringSettings"]["allowRegionSelection"] = true; let body = JSON.stringify(json); let newRes = new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers }) console.log('允许修改区域结束') resolve(newRes); }).catch(err => { reject(err); }); }).catch(err => { reject(err); }); }); }else if (url.indexOf('/v2/titles') > -1) { // /v2/titles or /v2/titles/mru // Enable CustomTouchOverlay console.log('修改触摸开始') return new Promise((resolve, reject) => { originFetch(...arg).then(res => { res.json().then(json => { // console.error(json); try { json["results"].forEach(result => { if (result["details"]["supportedInputTypes"].includes("CustomTouchOverlay") === false) { result["details"]["supportedInputTypes"].push("CustomTouchOverlay"); // console.log("[Xbox Cloud Gaming Global Touch Controll] Hook " + result["titleId"]); } if (result["details"]["supportedInputTypes"].includes("MKB") === false) { result["details"]["supportedInputTypes"].push("MKB"); // console.log("[Xbox Cloud Gaming Global Touch Controll] Hook " + result["titleId"]); } if (result["details"]["supportedInputTypes"].includes("GenericTouch") === false) { result["details"]["supportedInputTypes"].push("GenericTouch"); // console.log("[Xbox Cloud Gaming Global Touch Controll] Hook " + result["titleId"]); } if (result["details"]["supportedInputTypes"].includes("NativeTouch") === false) { result["details"]["supportedInputTypes"].push("NativeTouch"); // console.log("[Xbox Cloud Gaming Global Touch Controll] Hook " + result["titleId"]); } }); } catch (err) {} let body = JSON.stringify(json); let newRes = new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers }) resolve(newRes); console.log('修改触摸结束') }).catch(err => { reject(err); }); }).catch(err => { reject(err); }); }); }else { return originFetch(...arg); } } })();