0

我正在制作一个WebExtension将我的密码从我的网络服务器输入到input[type='password']网页上的字段中。

这是代码:

function getPW() {
    $.getJSON("http://mywebserver.org/p/?p=" + window.location.hostname, function(result){
        $.each(result, function(i, field){
            console.log("Field: " + field);
        });
    });
}

getPW();

现在,只执行console.log().

但是,当我加载它并打开 时Developer Tools,选项卡上的唯一输出Console是:

Password fields present on an insecure (http://) page. This is a security risk that allows user login credentials to be stolen.[Learn More]

这是我的网络服务器上的 PHP 代码:

<?php
    if(isset($_GET['p']) && $_GET['p'] != null) {
        $aaJSONData = ["Password" => "mySuperSecretPassword!")];
        header("Content-type: application/json");
        echo json_encode($aaJSONData);
    }
?>

并转到 URL:http://mywebserver.org/p/?p=stackoverflow.com在我的浏览器中显示:

{"Password":"mySuperSecretPassword!"}

这是我的manifest.json

{
    "manifest_version": 2,
    "name": "PWGen",
    "version": "1.0",

    "description": "Automatically fills out the <input type=\"password\"... /> part of the form",

    "applications": {
        "gecko": {
        "id": "my@ID"
        }
    },

    "content_scripts": [
        {
            "matches": ["*://*/*"],
            "js": ["jquery.js", "pwgen.js"]
        }
    ]
}

JQuery.js在文件夹中有最新的。

所以我猜这与我的getPW()功能有关。

我已经研究了 3 天来解决这个问题,只是让自己问了一个问题。

谢谢 :)

编辑:原来整个Same Origin Policy都阻止了我的请求。

那么有没有办法绕过Same Origin Policy呢?

4

0 回答 0