如何使用 POST 数据在 Firefox 中保存书签?

Eti*_*mps 24 firefox bookmarks http firefox-extensions

我想将无法使用 GET 访问的页面保存为 Firefox 书签。检索页面的唯一方法是发送一些 POST 数据。

例如,我想为Chronopost 包裹跟踪页面添加书签,该页面仅允许 POST 输入包裹编号。

有谁知道 Firefox 扩展程序或其他一些技术,可以让我这样做吗?

小智 21

使用书签。例如,您可以使用http://userjs.up.seesaa.net/js/bookmarklet.html上的工具通过以下代码创建书签:

(function(){
  var post_to_url = function(path, params, method) {
    var openWindow = window.open(path);
    method = method || "post"; 
    var form = openWindow.document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);
    for(var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);
        form.appendChild(hiddenField);
    }
    openWindow.document.body.appendChild(form);
    form.submit();
  };
post_to_url(
  'http://www.chronopost.fr/transport-express/livraison-colis/engineName/search/accueil/suivi', 
  {search:'test'});
})()
Run Code Online (Sandbox Code Playgroud)

然后将生成的书签链接用作您喜欢的浏览器中的书签。当您单击它时,它将打开一个窗口,使用参数创建一个表单{search:'test'},然后提交该表单。

要更改 URL 和参数,只需调整对post_to_url.

如果您只需要创建一次书签并多次使用它,则此策略非常有用。但是,如果您需要定期创建新书签,这并不容易。