我创建了一个javascript bookmarklet,获取当前页面的标题和URL,使用以下代码:

//Check to see if jQuery is already loaded
if (typeof jQuery == 'undefined') {
    var jQ = document.createElement('script');
    jQ.type = 'text/javascript';
    jQ.onload=runthis;
    jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
    document.body.appendChild(jQ);
} else {
    runthis();
}

// main Javascript function
function runthis() {
    title = document.title;
    url = document.URL;
    tag = "customTag";

    alert("Added to paperclip: Page Title: "+title+" | URL: "+url);
}
.

我现在想采取这个信息,并将其添加为我的美味帐户上的书签。我如何用JavaScript / jQuery来解决这个问题?我看了看 api文档,但我难以绕过它(全新为此,oauth使我的旋转旋转),并找不到任何完整的代码示例到批发。

真的会欣赏任何帮助/例子。

有帮助吗?

解决方案

编辑:

您可能想要查看此前问题。 - “我想在Firefox中创建一个美味的书签,将当前页面用预定义的标签书签。”


嗯,通过在浏览器的工具栏中使用书签来完全是您想要的一个例子是美味的书签。它从页面收集信息,在弹出窗口中显示信息,允许您编辑它,然后将其存储到您的帐户:

http://delicious.com/help/bookmarklet

javascript:(function(){
    f= 'http://delicious.com/save?url=' 
    + encodeURIComponent(window.location.href)
    + '&title='+encodeURIComponent(document.title)
    + '&v=5&';
    a=function(){
        if( !window.open(
            f + 'noui=1&jump=doclose',
            'deliciousuiv5',
            'location=yes,
            links=no,scrollbars=no,
            toolbar=no,width=550,height=550'))location.href=f + 'jump=yes'
    };
    if(/Firefox/.test(navigator.userAgent)){
        setTimeout(a,0)
    } else {
      a()
    }
})()
.


如果您使用Yahoo ID登录,您必须使用OAuth,但如果您没有,则可以使用像这样的v1 api(从此页

javascript:(

    function()
    {
        location.href = 'https://user:pwd@api.del.icio.us/v1/posts/add?url=' 
            + encodeURIComponent(window.location.href)
            + '&description=' + encodeURIComponent(document.title)   
            + '&tags=obvioustesttag';
    }

)()
.

确保搜索标签以获取“vervioustesttag”,因为它不会立即显示时间按时间顺序列表。

如果您当前使用yahoid来登录,则尝试创建常规登录或新帐户,否则,您将必须处理OAuth。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top