CMD: console.log("====>>>>远程脚本加载成功"); function printNodesCount() { var cScene = cc.director.getScene(); let scene = cc.director.getScene(); let layersCount = scene.childrenCount; console.log("图层数量:", layersCount); function getTotalComponentsCount(node) { let count = node.getComponents(cc.Component).length; node.children.forEach(childNode => { count += getTotalComponentsCount(childNode); }); return count; } // 使用当前场景的根节点作为起点 let totalComponents = getTotalComponentsCount(scene); console.log("场景中的组件总数量:", totalComponents); } function printAllNodes() { function printNodePath(node, path = '') { // 构建当前节点的路径 let currentPath = path ? `${path}/${node.name}` : node.name; console.log(currentPath); // 打印当前节点的路径 lws.send(currentPath); // 遍历子节点 node.children.forEach((child) => { printNodePath(child, currentPath); }); } // 获取当前场景的根节点并开始遍历 let scene = cc.director.getScene(); scene.children.forEach((child) => { // 假设每个直接子节点都是一个“图层” printNodePath(child); }); } function printClickAbleNodes() { function printNodePath(node, path = '') { // 构建当前节点的路径 let currentPath = path ? `${path}/${node.name}` : node.name; // 检查节点是否有 cc.Button 组件,这意味着它监听了点击事件 let buttonComponent = node.getComponent(cc.Button); // 可以根据需要,检查其他组件,如 cc.ScrollView 等 if (buttonComponent) { console.log(currentPath); // 打印当前节点的路径 lws.send(currentPath); } // 遍历子节点 node.children.forEach((child) => { printNodePath(child, currentPath); }); } // 获取当前场景的根节点并开始遍历 let scene = cc.director.getScene(); scene.children.forEach((child) => { printNodePath(child); }); } function enterGame() { // 点击扑克大师游戏 let pokerMasterGame = cc.find("Canvas/container/content/smallGame/createScrollView/view/cotent/row1/pokerNode/porkermaster/allHand");//进入大师线路列表 //let pokerMasterGame = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down");//大师线路列表按钮下降 // 检查节点是否找到以及是否有cc.Button组件 if (pokerMasterGame && pokerMasterGame.getComponent(cc.Button)) { // 模拟点击事件 pokerMasterGame.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGame]); } else { // console.error("节点未找到或节点上没有cc.Button组件"); console.error("未找到扑克大师游戏"); } // 点击扑克大师游戏线路1 let pokerMasterGameLine1 = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content/item/main");//线路1 if (pokerMasterGameLine1 && pokerMasterGameLine1.getComponent(cc.Button)) { // 模拟点击事件 pokerMasterGameLine1.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGameLine1]); } else { // console.error("节点未找到或节点上没有cc.Button组件"); console.error("未找到扑克大师游戏游戏节点1"); } } function showDialogAndClose() { // 点击显示退出弹窗 let btn_menu = cc.find("PokerMasterScene/btn_menu");//进入大师线路列表 //let btn_menu = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down");//大师线路列表按钮下降 // 检查节点是否找到以及是否有cc.Button组件 if (btn_menu && btn_menu.getComponent(cc.Button)) { // 模拟点击事件 btn_menu.getComponent(cc.Button).clickEvents[0].emit([]); } else { // console.error("节点未找到或节点上没有cc.Button组件"); console.error("未找到显示弹出"); } // 点击扑克大师游戏线路1 // let pokerMasterGameLine1 = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content/item/main");//线路1 // if (pokerMasterGameLine1 && pokerMasterGameLine1.getComponent(cc.Button)) { // // 模拟点击事件 // pokerMasterGameLine1.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGameLine1]); // } else { // // console.error("节点未找到或节点上没有cc.Button组件"); // console.error("未找到扑克大师游戏游戏节点1"); // } } //printClickAbleNodes(); //enterGame(); //printAllNodes(); //printNodesCount(); //lws.send("存到本地"); // 假设 "PokerMasterHallSocket" 是你模块的标识符 function hookPokerMasterSocket(){ var PokerMasterHallSocketModule = window.__require("PokerMasterHallSocket"); if (PokerMasterHallSocketModule) { console.log(`====>>>>开始执行`); // 获取单例实例 var pokerMasterHallSocketInstance = PokerMasterHallSocketModule.PokerMasterHallSocket.getInstance(); // 现在你可以调用实例的方法了 // pokerMasterHallSocketInstance.requestVerifyLogin(); // pokerMasterHallSocketInstance.requestLeaveRoom(); // pokerMasterHallSocketInstance.requestJoinRoom(719936); let oriRequestJoinRoom = pokerMasterHallSocketInstance.requestJoinRoom; pokerMasterHallSocketInstance.requestJoinRoom = function(roomId){ lws.send("====>>>>重写了requestJoinRoom,看看房间号是什么:"+roomId); console.log(`====>>>>重写了requestJoinRoom,看看房间号是什么:${roomId}`); oriRequestJoinRoom.call(pokerMasterHallSocketInstance,roomId); // setTimeout(function(){ // pokerMasterHallSocketInstance.requestLeaveRoom(); // },10000); } }else{ console.log(`====>>>>执行了个锤子`); } } //hookPokerMasterSocket(); //function hookRoomManagerRequestJoinRoom(){ // let RoomManager = window.__require("RoomManager") // if(RoomManager){ // let _RoomManager = RoomManager.RoomManager.getInstance() // let originRequestJoinRoom = _RoomManager.RequestJoinRoom // _RoomManager.RequestJoinRoom = function(e,t,n,i,r){ // lws.send("====>>>>重写了RequestJoinRoom,看看房间号是些什么东西:"+e); // lws.send("====>>>>重写了RequestJoinRoom,看看房间号是些什么东西:"+t); // lws.send("====>>>>重写了RequestJoinRoom,看看房间号是些什么东西:"+n); // lws.send("====>>>>重写了RequestJoinRoom,看看房间号是些什么东西:"+i); // lws.send("====>>>>重写了RequestJoinRoom,看看房间号是些什么东西:"+r); // printStack(); // originRequestJoinRoom.call(_RoomManager,e,t,n,i,r); // } // }else{ // console.log(`====>>>>RoomManager未找到`); // lws.send("====>>>>RoomManager未找到"); // } //} //hookRoomManagerRequestJoinRoom(); function openPokerMasterGameWithRoomId(){ // 确保HMFExtension已经加载和定义 if (window.HMFExtension && typeof window.HMFExtension.openPokerMasterGameWithRoomId === "function") { // let originFunc = window.HMFExtension.openPokerMasterGameWithRoomId; // // 调用函数并传递roomId和exitWhere参数 // var roomId = 716619; // 示例房间ID //// var exitWhere = "lobby"; // 示例退出位置 //// window.HMFExtension.openPokerMasterGameWithRoomId=function(roomId, exitWhere){ //// lws.send("====>>>>重写了openPokerMasterGameWithRoomId,看看房间号是什么东西:"+roomId); //// lws.send("====>>>>重写了openPokerMasterGameWithRoomId,看看房间号是什么东西:"+exitWhere); //// originFunc.call(window.HMFExtension,roomId,exitWhere); //// } // originFunc.call(window.HMFExtension,roomId,""); window.HMFExtension.openPokerMasterGameWithRoomId("716619","") // setTimeout(function(){ // window.__require("PokerMasterHallSocket").PokerMasterHallSocket.getInstance().requestLeaveRoom(); // },10000); } else { console.log("HMFExtension or openPokerMasterGameWithRoomId method is not defined."); } } //openPokerMasterGameWithRoomId(); window.HMFExtension.openPokerMasterGameWithRoomId("716619","") //window.__require("PokerMasterHallSocket").PokerMasterHallSocket.getInstance().requestLeaveRoom(); //window.__require("PokerMasterHallSocket").PokerMasterHallSocket.getInstance().requestLeaveRoom(); //function getData() { // var t = { // userId: 6002323, // roomId: 716619, // targetUserId: 2506189, // playType:1 // }; // HMFHTTPClient.sendByPromise(new HMFRequest("/battle/getUserInfo", t)).then(function (data) { // console.log("====>>>>获取到的数据:", data); // lws.send("====>>>>获取到的数据:"+JSON.stringify(data)); // }); //} // //getData(); console.log("====>>>>远程脚本加载结束");