WOT 书签
我正在尝试编写一个小书签,以便查看 Web Of Trust (WOT) 的评级在访问页面上的所有链接之前。虽然 WOT 提供了自己的书签,但它不是很有用,因为您需要先访问该页面才能查看评级。这将在 SeaMonkey 上使用,所以我也不能只安装 WOT 扩展。
WOT 有一个 Javascript API,允许您在其包含的任何页面上激活评级,所以我用它作为基础。然而,它作为一个书签似乎永远无法正常工作。这是我尝试让代码尽可能接近 API 的尝试。我只修改了 wotinject 函数,以便它可以在小书签中工作,并添加一个超时,以便评级小部件不会在 jQuery 之前加载。
var wotprotocol = (document.location.protocol == "https:") ? "https://" : "http://";
var wotbase = wotprotocol + "api.mywot.com/widgets";
var wotinject = function(src) {
document.body.appendChild(document.createElement("script")).src = wotbase + "/" + src + ".js";
};
var wotjquery = typeof(jQuery) != "undefined";
if (!wotjquery) {
wotinject("jquery");
}
void(window.setTimeout(wotinject, 200, "ratingwidget"));
我可以在状态栏中看到正在加载的 API,但它根本没有执行任何操作。有什么办法可以让它发挥作用吗?
I'm trying to write a bookmarklet that will allow me to view the Web Of Trust (WOT) ratings for all the links on a page before visiting them. While WOT provides their own bookmarklet, it is not very useful since you need to visit the page first before viewing the rating. This will be used on SeaMonkey, so I can't just install the WOT extension, either.
WOT has a Javascript API that allows you to activate the ratings on any page it is included in, so I am using that as a base. However, it never seems to work correctly as a bookmarklet. Here's one attempt where I tried to keep the code as close to the API as possible. I only modified the wotinject function so that it would work in a bookmarklet and added a timeout so that the rating widget wouldn't be loaded before jQuery.
var wotprotocol = (document.location.protocol == "https:") ? "https://" : "http://";
var wotbase = wotprotocol + "api.mywot.com/widgets";
var wotinject = function(src) {
document.body.appendChild(document.createElement("script")).src = wotbase + "/" + src + ".js";
};
var wotjquery = typeof(jQuery) != "undefined";
if (!wotjquery) {
wotinject("jquery");
}
void(window.setTimeout(wotinject, 200, "ratingwidget"));
I can see the APIs being loaded in the status bar, but it doesn't do anything at all. Is there any way to get this working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否能回答您的问题,但我在生产中使用了一个加载 jQuery 的书签。这段代码对我来说效果很好:
I'm not sure if this answers your question, but I use a bookmarklet in production that loads jQuery. This code works fine for me: