且听疯吟 在此记录扯淡的青春
Bing 云词典书签 Bookmarklet

一个页面查询词典用的书签,api 来自 Bing

复制下面这段作为新建书签的地址

javascript:(function(){javascript:(function(){if(document.location.protocol=="https:"){alert("bing bookmarklet: https not supported!");}else{script=document.createElement('script');script.src='http://dict.bing.com.cn/cloudwidget/Scripts/Generated/BingTranslate_Hover_Phrase_Selection_ShowIcon.js';script.onload=function(){BingCW.Init({AppID:"dict",MachineTranslation:true,WebDefinition:true});};document.body.appendChild(script);}})();})();

展开的代码如下

javascript: (function() {
    if (document.location.protocol == "https:") {
        alert("bing bookmarklet: https not supported!");
 
    } else {
        script = document.createElement('script');
        script.src = 'http://dict.bing.com.cn/cloudwidget/Scripts/Generated/BingTranslate_Hover_Phrase_Selection_ShowIcon.js';
        script.onload = function() {
            BingCW.Init({
                AppID: "dict",
                MachineTranslation: true,
                WebDefinition: true
            });
        };
        document.body.appendChild(script);
    }  
})();

由于源 js 文件没有使用加密连接,因此在 https 下无法引入,可以试试将源 js 托管到支持加密连接的网站

完整代码:https://gist.github.com/caoyue/3abd20ab8da6e404cd1a

  • posted on 2015-05-12 17:22
  • project