任何人都可以告诉如何复制整个页面类似于按Ctrl + A然后将当前选项卡复制到剪贴板.
目前我有这个,但它没有做任何事情虽然扩展已成功添加到chrome:
清单文件
"permissions":
[
"clipboardRead",
"clipboardWrite"
],
// etc
Run Code Online (Sandbox Code Playgroud)
内容脚本
chrome.extension.sendRequest({ text: "text you want to copy" });
Run Code Online (Sandbox Code Playgroud)
背景页面
<html>
<head>
<script type="text/javascript">
chrome.extension.onRequest.addListener(function (msg, sender, sendResponse) {
var textarea = document.getElementById("tmp-clipboard");
// now we put the message in the textarea
textarea.value = msg.text;
// and copy the text from the textarea
textarea.select();
document.execCommand("copy", false, null);
// finally, cleanup / close the connection
sendResponse({});
});
</script>
</head>
<body>
<textarea id="tmp-clipboard"></textarea>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
弹出
<textarea id="tmp-clipboard"></textarea>
<input type="button" …
Run Code Online (Sandbox Code Playgroud) javascript browser plugins google-chrome google-chrome-extension
我想从Jquery的网站上获取一个favicon的链接.我只是使用$('link[rel="shortcut icon"]').attr('href');
它,它工作正常.
但是......我并不总是有一条完整的道路.例如,我可以有类似的东西
http://mywebsite.com/myicon.ico
Run Code Online (Sandbox Code Playgroud)
或者只是相对路径
/myicon.ico
Run Code Online (Sandbox Code Playgroud)
即使Url被编码为相对路径,我也希望始终拥有完整路径.有一个简单的解决方案吗?
我将其用作Google Chrome扩展程序中的内容脚本.
我正在尝试创建一个非常简单的chrome扩展,以便在单击时在新选项卡中打开硬编码链接,并且我没有任何运气.添加扩展后,图标显示,但单击它时没有任何反应.有什么建议?
的manifest.json
{
"name": "Drive Button",
"version": "1.0",
"manifest_version": 2,
"description": "Open Google Drive",
"browser_action": {
"default_icon": "icon.png"
},
"background": "background.html",
"permissions": [
"tabs"
]
}
Run Code Online (Sandbox Code Playgroud)
background.html
<html>
<head>
<script>
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({url: "http://drive.google.com"});
});
</script>
</head>
</html>
Run Code Online (Sandbox Code Playgroud) 是否可以在 Chrome 扩展程序中捕获整个页面的屏幕截图,包括折叠下方的内容?
该captureVisibleTab似乎只限于什么是可视区域内显示。
我尝试在Google上搜索并阅读文档 但没有成功.我正在使用contentScript(chrome扩展)或firefox用户称为greasemonkey脚本来制作ajax请求.
使用AJAX获取URL的典型函数,
function getURL(url, element)
{
var request = new XMLHttpRequest();
request.onreadystatechange = function()
{
if ( request.readyState == 4 )
{
callback( request.responseText, element, request.status );
}
};
request.open( "GET", url, true );
request.send()
}
Run Code Online (Sandbox Code Playgroud)
可以说我只需要第一个10kb的页面,但是whole size of page is more than 200kb
.我正在检索的页面是普通的HTML.我不想waste the bandwidth by downloading the excess 190kb
.有没有办法实现这一目标?另外,如果只检索100kb到110kb的页面的一部分可能吗?
我对浏览器特定的解决方案(chrome)持开放态度.我必须将扩展程序移植到Firefox,所以也欢迎这方面的想法.