Javascript 从chrome扩展访问网站数据
我有一个分机,我希望它能做到以下几点:Javascript 从chrome扩展访问网站数据,javascript,google-chrome,scripting,google-chrome-extension,google-chrome-devtools,Javascript,Google Chrome,Scripting,Google Chrome Extension,Google Chrome Devtools,我有一个分机,我希望它能做到以下几点: 当用户双击并选择一个单词时,检测该单词 在word上执行一些操作,并在工具提示之类的小交互页面上显示结果 我在找像这样的东西 有人能帮我吗?我该怎么办 提前谢谢。Morteza选择文本时,所选文本将显示在警报窗口中。一个好的起点 manifest.json { "name": "Selecty thingy", "version": "1.0.1", "manifest_version": 2, "description": "Select
提前谢谢。Morteza选择文本时,所选文本将显示在警报窗口中。一个好的起点 manifest.json
{
"name": "Selecty thingy",
"version": "1.0.1",
"manifest_version": 2,
"description": "Selecty thingy",
"browser_action": {
},
"permissions": [
"tabs", "*://*/*"
],
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["jquery-1.7.2.min.js","content_script.js"],
"run_at": "document_end"
}
]
}
content\u script.js
$(document).ready(function(){
$('html').mouseup(function() {
var selectedText = getSelectedText();
if(selectedText > ''){
alert(selectedText);
}
});
function getSelectedText() {
if (window.getSelection) {
var selection = window.getSelection().toString();
if(selection.trim() > ''){
return selection;
}
} else if (document.selection) {
var selection = document.selection.createRange().text;
if(selection.trim() > ''){
return selection;
}
}
return '';
} });
这是一个显示chrome扩展之外的功能的示例…当选择文本时,所选文本将显示在警报窗口中。一个好的起点 manifest.json
{
"name": "Selecty thingy",
"version": "1.0.1",
"manifest_version": 2,
"description": "Selecty thingy",
"browser_action": {
},
"permissions": [
"tabs", "*://*/*"
],
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["jquery-1.7.2.min.js","content_script.js"],
"run_at": "document_end"
}
]
}
content\u script.js
$(document).ready(function(){
$('html').mouseup(function() {
var selectedText = getSelectedText();
if(selectedText > ''){
alert(selectedText);
}
});
function getSelectedText() {
if (window.getSelection) {
var selection = window.getSelection().toString();
if(selection.trim() > ''){
return selection;
}
} else if (document.selection) {
var selection = document.selection.createRange().text;
if(selection.trim() > ''){
return selection;
}
}
return '';
} });
这是一个展示chrome扩展之外的功能的示例…如果你想“做一些类似的事情”,只需看看他们的源代码即可。安装扩展可以很容易地做到这一点(只需点击一下查看源代码)。大多数js代码都是最小的,并且很难在上面链接的扩展自动美化代码。有些代码仍然相对难以理解,即使经过美化。非常感谢Rob。它非常有用。是否有任何类似于上述扩展的工具来美化min.js代码,超出扩展位置。如果你想“做一些类似的事情”,只要看看他们的源代码就可以了。安装扩展可以很容易地做到这一点(只需点击一下查看源代码)。大多数js代码都是最小的,并且很难在上面链接的扩展自动美化代码。有些代码仍然相对难以理解,即使经过美化。非常感谢Rob。它非常有用。是否有任何类似于上述扩展的工具来美化min.js代码,超出扩展位置。也