为Chrome创建一个类似StumbleUpon的工具栏 [英] Creating a StumbleUpon-like toolbar for Chrome

查看:118
本文介绍了为Chrome创建一个类似StumbleUpon的工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能做到这一点?我已阅读文档,但我发现我只能有图标,工具提示,徽章和一个弹出窗口。我想让它成为一个类似StumbleUpon的工具栏。然后我想到了使用ContentScripts,但我不知道在哪里添加html注入,因为根据到文档我只有js或css的选项。



我有一个js文件:

 (body)。before('< div name =extension-topid =extension-top>< / div>'); 
var top = document.getElementById(extension-top);
document.getElementsByTagName('body')[0] .style.marginTop ='40px';
top.src = chrome.extension.getURL(popup.html);

和css:

 #extension-top {width:100%;高度:40像素;顶部:0;左:0;背景:#000; margin:0; padding:0;} 

最后一个html:

 < body id =extension-content> 
HELLO
< / body>

栏显示,但hello不在任何地方可见= /

解决方案

有一个实验性的Infobar API,可以用来创建类似StumbleUpon的工具栏。有关文档和示例,请参阅 Infobars



请注意,在API稳定之前,您无法将扩展程序发布到Chrome网上应用店。


How can I get to do this? I've read the documentation but I find I can only have icon, a tooltip, a badge, and a popup. And I want to make it a StumbleUpon-like toolbar. Then I thought about using ContentScripts but I don't know where to add the html to inject because according to the documentation I only have the options of js or css. What am I missing here?

I have a js file:

$("body").before('<div name="extension-top" id="extension-top"></div>');
var top = document.getElementById("extension-top");
document.getElementsByTagName('body')[0].style.marginTop = '40px';
top.src = chrome.extension.getURL("popup.html");

and css:

#extension-top { width:100%; height:40px; top:0; left:0; background:#000;margin:0;padding:0;}

finally an html:

<body id="extension-content">
    HELLO
</body>

The bar shows up but the "hello" isn't anywhere to be seen =/

解决方案

There is an experimental Infobar API that you could use to make a StumbleUpon-like toolbar. See Infobars for documentation and examples.

Note that you won't be able to publish the extension to the Chrome Web Store until the API becomes stable.

这篇关于为Chrome创建一个类似StumbleUpon的工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆