如何使用Chrome文档中的文件而不是URL
How to use files from the Chrome document instead of a URL?
我是一个大傻瓜,所以我会尽我所能解释这一点。总之,我正在学习扩展开发的步骤,我想把Greasemonkey脚本和Firefox插件中的元素融合在一起。到目前为止,我已经完成了一些工作,但我似乎不知道如何从脚本指向Chrome:Skin
文件夹来制作图像和CSS文件
当前代码为:
var newstyle = document.createElement('link');
newstyle.rel = 'stylesheet';
newstyle.href = 'http://example.com/test.css';
newstyle.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(newstyle);
function main(){
var assets = Math.floor(Math.random()*8);
$('<div id="jumpFloatingButton" style="width:80px;height:30px;background-color:#21a0f1;background-image:url(http://colourlovers.com.s3.amazonaws.com/images/patterns/2757/2757110.png);position:fixed;right:0px;bottom:0px;background-attachment: scroll;cursor: pointer;"></div>').insertAfter('body *:last');
$('<div id="jumpFloating" style="width:400px;height:500px;position:fixed;bottom:30px;right:0px;border:1px solid black;background-image:url(http://colourlovers.com.s3.amazonaws.com/images/patterns/2757/2757110.png);"><ul id="jumpFloatingList" style="overflow:auto;max-height:500px;max-width:400px;margin-left:0px;"></ul></div>').insertAfter('#jumpFloatingButton');
上面代码中的链接是从其他来源链接的文件的示例。我想知道的是,如何从加载项的文件夹中而不是其他URL中创建链接点?类似:
newstyle.href = 'chrome://folder/skin/overlay.css';
或
$('<div id="jumpFloatingButton" style="width:80px;height:30px;background-color:#21a0f1;background-image:url(chrome://folder/skin/image.jpg);position:fixed;right:0px;bottom:0px;background-attachment: scroll;cursor: pointer;"></div>').insertAfter('body *:last');
我使用Netbeans。我的舱单
content file jar:chrome/file.jar!/content/
skin special classic/1.0 jar:chrome/special.jar!/skin/ contentaccessible=yes
我试过
var newstyle = document.createStyleSheet('overlay.css');
newstyle.rel = 'stylesheet';
newstyle.href = 'chrome://nb/skin/overlay.css';
newstyle.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(newstyle);
添加document.createStyleSheet会修复它吗?我的编辑
$('<div id="imagestack" style="width:304px;height:64px;background-image:url("chrome://special/skin/nav.png");
您需要将chrome.manifest
中的chrome://folder/
标记为可从web访问,否则网页将无法加载它。我看到您已经尝试过了,但您将contentaccessible=yes
添加到了skin
条目中。文件上写着:
contentaccessible标志仅适用于内容包:区域设置或外观注册无法识别它。但是,匹配的语言环境和皮肤包也将暴露在内容中。
这是因为你不能将chrome包的一部分标记为可访问网络——要么是全部(内容、皮肤和区域设置),要么什么都没有。所以你的chrome.manifest
应该是这样的:
content file jar:chrome/file.jar!/content/ contentaccessible=yes
skin special classic/1.0 jar:chrome/special.jar!/skin/
相关文章:
- 直接下载文件,而不是从window.open(url)
- CKFinder 3为所选文件返回错误的URL
- 将CSV文件从URL导入Node.js
- 如何从“”运行url;.js”;文件
- 如何在不在本地下载的情况下将url中提供的文件(pdf/doc)转换为json/string/base64格式
- 如何使用javascript或jquery mobile从url读取和显示XML文件
- gcloud节点-我如何确保通过签名URL上传到谷歌云存储的文件是公开可读的
- 将任何CDN配置为只传递一个文件,无论请求的url是什么
- jqueryajax调用是复制url,当在模态视图之后在外部js文件中进行调用时
- 生成的excel文件url
- 如何在PHP中使用url保护我的图像和文件夹免受直接访问
- 如何使用phonegap从android中的URL下载文件
- 读取不带fs的txt文件nodejs(来自url)
- 检查蒸汽配置文件url是否有效
- ExtJS:从受保护的url创建JSB3文件
- 将 MVC 3 应用程序部署到 URL 文件夹已损坏 JavaScript 和内容路径
- 如何获取JSON URL文件并使其不断更新
- 获取远程加载图像的url's文件大小
- JS智能感知不工作的外部URL文件在VS2012
- ASP.. NET - windows . open (URL) -文件被缓存,我如何停止它