浏览器本机注入
Browser Native Injection
遵循以下脚本:#content_script.js,这是一种注入代码以获取参数中传递的值的方法。
或者更清楚(它可以是任何JavaScript的函数):
(function() {
var parse = JSON.parse;
JSON.parse = function(){
console.log('Getting params: ', arguments);
return parse.apply(JSON, arguments)
};
JSON.parse.toString = function(){ return 'function parse() { [native code] }' };
var wss = WebSocket.prototype.send;
WebSocket.prototype.send = function(){
console.log('Getting params', arguments);
return wss.apply(this, arguments)
}
WebSocket.prototype.send.toString = function(){ return 'function send() { [native code] }' }
})();
但是,在网络游戏中,我不应该使用这种方法,而是想将其注入JavaScript引擎(Native Code
)。不完全是我想知道如何发展,如果没有,我该怎么办?。如果我必须使用另一种编程语言或某种方法来做它?
这很容易做到。下面的所有代码都是模板代码,这意味着所有插件都可以进行通用的复制粘贴,只需稍作调整。这里有一个关于如何编写firefox引导插件的小教程。它与这里基本相同,但针对您的工作进行个性化设置:https://gist.github.com/Noitidart/9025999(我没有包括图标和本地化等细节)
- 在计算机上创建一个空文件夹
- 在其中制作这些空白的新文件:bootstrap.js和install.rdf以及chrome.manifest和inject.js
-
将此模板粘贴到install.rdf中:
<?xml version="1.0" encoding="utf-8"?> <!-- This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <Description about="urn:mozilla:install-manifest"> <em:id>Bootstrap-Skeleton@jetpack</em:id> <em:version>initial</em:version> <em:type>2</em:type> <em:bootstrap>true</em:bootstrap> <em:unpack>false</em:unpack> <!-- Firefox --> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>7.0</em:minVersion> <em:maxVersion>27.0</em:maxVersion> </Description> </em:targetApplication> <!-- Front End MetaData --> <em:name>Bootstrap Skeleton</em:name> <em:description>How all bootstrap addons start.</em:description> <em:creator>Noitidart</em:creator> <em:contributor>Pat for Icon</em:contributor> <em:optionsType>2</em:optionsType> </Description> </RDF>
-
现在,在我们粘贴的内容中,让我们用
DragonboundCheater@wZVanG
替换<em:id>
的内容 - 让我们将
<em:name>
更新为我们想要的插件名称,并将其命名为Dragonbound Cheater
- 现在保存并转到bootstrap.js
-
在bootstrap.js中粘贴此模板:
function startup(aData, aReason) {} function shutdown(aData, aReason) { if (aReason == APP_SHUTDOWN) return; } function install() {} function uninstall() {}
-
现在用以下内容更新其内容:
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import('resource://gre/modules/Services.jsm'); var browserWinAddedTo; function startup(aData, aReason) { var recentBrowserWindow = Services.wm.getMostRecentWindow('navigator:browser'); browserWinAddedTo = recentBrowserWindow; if (recentBrowserWindow.document.readyState == 'complete') { //on startup `aDOMWindow.document.readyState` is `uninitialized` recentBrowserWindow.messageManager.loadFrameScript('chrome://dragonboundcheater@wzvang/content/inject.js'); } else { recentBrowserWindow.addEventListener('load', function () { recentBrowserWindow.removeEventListener('load', arguments.callee, false); recentBrowserWindow.messageManager.loadFrameScript('chrome://dragonboundcheater@wzvang/content/inject.js'); }, false); } } function shutdown(aData, aReason) { if (aReason == APP_SHUTDOWN) return; browserWinAddedTo.messageManager.removeDelayedFrameScript('chrome://dragonboundcheater@wzvang/content/inject.js'); } function install() {} function uninstall() {}
-
在chrome.manifest中添加以下内容:
content dragonboundcheater ./
-
现在,在inject.js中,我们可以做任何js想要做的事情,但让我们首先确保主机匹配,并查看https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Frame_script_environment这告诉我们window对象是由全局变量
content
引用的,所以无论我们想访问哪里,我们都使用content
,如果你想访问js环境,我们使用content.wrappedJSObject
。因此,让我们将inject.js设为:(function() { var window = content; var js = window.wrappedJSObject; if (window.location.host.indexOf('dragonbound.net') == -1) { return; } var parse = js.JSON.parse; js.JSON.parse = function(){ console.log('Getting params: ', arguments); return parse.apply(js.JSON, arguments) }; js.JSON.parse.toString = function(){ return 'function parse() { [native code] }' }; var wss = js.WebSocket.prototype.send; js.WebSocket.prototype.send = function(){ console.log('Getting params', arguments); return wss.apply(this, arguments) } js.WebSocket.prototype.send.toString = function(){ return 'function send() { [native code] }' } })();
-
然后将文件夹中的所有内容压缩,将其从.zip重命名为.xpi,并拖动到firefox和voila中:)
- '图片'没有用于本机道具的propType'RCTImageView.overlayColor&
- 在iOS和Android上使用React native时,我还能使用本机第三方lirbraries吗
- javascript函数访问ios本机功能
- 如何在从客户端接收数据时从本机方法触发javascript函数?
- 在浏览器中检测本机或第三方PDF插件
- 将事件发送到javascript文档的react本机模块是否正确
- 将对应用内购买的支持构建为react本机代码
- 如何在Windows上用javascript构建本机应用程序
- 在视图中渲染多个按钮以编程方式进行本机反应
- 在本机挂钩之前加载可安装挂钩
- 如何使用UI Automation JavaScript Reference for iOS appium获取本机应用程
- 控制台中的“function floor(){[本机代码]}”是什么
- 如何将chrome.tabCapture流从js传递到c++PNACL本机代码
- WKWebview-Javascript和;本机代码
- 将回调/函数从本机发送到javascript
- 为什么我得到Chrome本机消息“;找不到指定的本机消息传递主机&”;
- 检测未绑定的本机函数,如“Array.push”
- 离子 - 本机对话框
- 如何获取 jQuery 以触发本机自定义事件处理程序
- 浏览器本机注入