小编Wat*_*onN的帖子

Safari扩展消息

我一直在开发Safari扩展程序并且已经碰壁了.我无法弄清楚如何从全局向注入发送多行数据.我一直在这个网站和其他人搜索一段时间,只发现了点点滴滴,但是当它们合并失败时.

下面我需要摆脱Global
safari.extension.secureSettings.username;
safari.extension.secureSettings.password;
我已经尝试将它们放入全局变量但是注入没有看到那些.

注入代码

document.getElementById('local_login').style.display='';
document.getElementById('local_login_link').style.display = 'none';
document.loginForm.username.value = /*Safari Secure Settings Username*/
document.loginForm.password.value = /*Safari Secure Settings Password*/
document.getElementById('localsubmit').click();
Run Code Online (Sandbox Code Playgroud)

我尝试了Apple文档中的代码,但它不会运行任何注入代码.

编辑 这是我到目前为止所拥有的.我只是不确定它为什么没有接收或发送.

Global.html

function sendCred() {
    myUsername = safari.extension.secureSettings.username;
    myPassword = safari.extension.secureSettings.password;
    var arrayNSA = [myUsername, myPassword];
    safari.self.tab.dispatchMessage("nsaArray", arrayNSA);
}

safari.application.addEventListener("messageFromNSA", sendCred, false);
Run Code Online (Sandbox Code Playgroud)

Inject.js

function showForm() {
    document.getElementById('local_login').style.display='';
    document.getElementById('local_login_link').style.display = 'none';
    document.loginForm.username.value = myNSAusername;
    document.loginForm.password.value = myNSApassword;
    document.getElementById('localsubmit').click();
}

function recieveCred(msgEvent) {
   var nsaMessageName = msgEvent.name;
   var nsaMessageData = msgEvent.message;
   if (nsaMessageName === "nsaArray") {
       var …
Run Code Online (Sandbox Code Playgroud)

javascript safari safari-extension

2
推荐指数
1
解决办法
5000
查看次数

标签 统计

javascript ×1

safari ×1

safari-extension ×1