electron获取本地javascript文件的URL并返回该URL
我正在尝试模仿一些在chrome扩展中很容易实现的行为,现在我的应用程序越来越大,我正在尝试将electron重建为一个独立的应用程序 可悲的是,我遇到了一个问题,我试图为某个网页提供我自己的js。在chrome扩展中,我将通过以下方式实现:electron获取本地javascript文件的URL并返回该URL,javascript,node.js,google-chrome-extension,electron,Javascript,Node.js,Google Chrome Extension,Electron,我正在尝试模仿一些在chrome扩展中很容易实现的行为,现在我的应用程序越来越大,我正在尝试将electron重建为一个独立的应用程序 可悲的是,我遇到了一个问题,我试图为某个网页提供我自己的js。在chrome扩展中,我将通过以下方式实现: chrome.webRequest.onBeforeRequest.addListener(function (details) { console.log("Patched init.js"); ret
chrome.webRequest.onBeforeRequest.addListener(function (details) {
console.log("Patched init.js");
return {redirectUrl: chrome.extension.getURL("init.js")};
}, {urls: ["https://example.com/js/init.js"]}, ["blocking"]);
我就是找不到正确的方法来做电子。我真的需要它来返回本地修改的js文件
我可以为onBeforeRequest使用什么,但遗憾的是,我仍然没有像chrome扩展名那样的本地文件(getUrl函数)
如果有人对这个解决方案感兴趣,我想在electron应用程序中创建一个带有静态节点的小型web服务器就足够了。然后我使用localhost:port/staticmap/my.js作为URL,而不是extention.getURL()
session.defaultSession.webRequest.onBeforeRequest(function (details) {
console.log("Patched jQuery");
return {redirectUrl: getUrlFunctionNeeded("init")};
}, {urls: ["https://example.com/js/init.js"]}, ["blocking"]);
Best regards