我已经尝试了很多方法(所有文档化的程序),在检查onUpdated.addListener上的URL时将脚本注入特定页面.最后,带有'executioncript'的下面代码似乎有效,但并不完美.我能够获取警报,但无法通过getElementById/getElementsByName查找页面的文档元素.
当我检查页面时,脚本被注入.但在错误控制台中,我得到:
拒绝加载chrome-extension://jfeiadiicafjpmaefageabnpamkapdhe/js/Leoscript.js.资源必须列在web_accessible_resources清单键中,以便由扩展名外的页面加载.
manifest.json的:
{
"name": "Leo Extension for Job Boards",
"version": "1.6",
"manifest_version": 2,
"content_security_policy": "script-src 'self'; object-src 'self'",
"description": "Leo Extension",
"background": {
"scripts": ["js/Leojshelper.js"],
"persistent": true
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["js/eventPage.js"],
"run_at" : "document_start"
}
],
"icons":{"48":"images/bob48.png", "128":"images/bob128.png"}, //Define any icon sizes and the files that you want to use with them. 48/128 etc.
"browser_action": {
"default_icon": "images/bob.png", // What icon do you want to display on the chrome toolbar
"default_popup": "LeoExtwatch.html" // The …
Run Code Online (Sandbox Code Playgroud) 我想通过浏览器操作按钮打开它时更新popup.html中的html.popup.js应该向当前选项卡上运行的内容脚本发送消息,并且应该收到响应并更新html.但是,内容脚本不会收到任何消息,因此不会发送正确的响应.
Content.js
var text = "hello";
chrome.runtime.onMessage.addListener(
function(message, sender, sendResponse) {
switch(message.type) {
case "getText":
sendResponse(text);
break;
}
}
);
Run Code Online (Sandbox Code Playgroud)
Popup.js
chrome.tabs.getCurrent(function(tab){
chrome.tabs.sendMessage(tab.id, {type:"getText"}, function(response){
alert(response)
$("#text").text(response);
});
});
Run Code Online (Sandbox Code Playgroud)
的manifest.json
{
"manifest_version": 2,
"name": "It's Just A Name",
"description": "This extension is able to",
"version": "1.0",
"permissions" : ["tabs"],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "Click here!"
},
"content_scripts": [
{
"matches": ["https://*/*"],
"js": ["jquery.min.js","content.js"]
}]
}
Run Code Online (Sandbox Code Playgroud)
Popup.html
<!doctype html>
<html>
<head>
<title>Title</title>
<style>
body {
font-family: "Segoe UI", …
Run Code Online (Sandbox Code Playgroud) 当我使用chrome devtools时,我很奇怪.但似乎typeof <object>
是一个"功能".
我没有找到任何解释或参考.
这是一个简单的例子:https
://jsfiddle.net/fez34zbf/
HTML:
<object></object>
<video></video>
Run Code Online (Sandbox Code Playgroud)
JS:
console.log(typeof document.querySelector('object'));
console.log(typeof document.querySelector('video'));
Run Code Online (Sandbox Code Playgroud)
控制台结果将是:
function
object
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我知道,没有办法直接从亚马逊上的t1.micro迁移到t2.micro.
那么,它会起作用吗:
数据安全吗?
这是我验证域名的代码.
function frmValidate() {
var val = document.frmDomin;
if (/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/.test(val.name.value)) {
}
else {
alert("Enter Valid Domain Name");
val.name.focus();
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
和
<form name="frmDomin" action="" method="post" onsubmit="return frmValidate();">
Domain Name : <input type="text" value="" id="name" name="name" />
</form>
Run Code Online (Sandbox Code Playgroud)
现在我进入了http://devp1.tech.in
它并提醒消息.我也想进入子域名.怎么改变这个?我不应该警惕.
我正在尝试上传我的第一个Google Chrome扩展程序,但出现了一个奇怪的问题。
我的清单文件如下:
{
"manifest_version": 2,
"name": "Chat About",
"description": "Chat about the content of the web page you're currently visiting with other visitors.",
"version": "0.0.1.1",
"icons":
{
"16": "icon16.png",
"32": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"browser_action":
{
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions":
[
"activeTab"
]
}
Run Code Online (Sandbox Code Playgroud)
源目录的内容如下:
icon.png
icon128.png
icon16.png
icon32.png
icon48.png
manifest.json
popup.html
popup.js
Run Code Online (Sandbox Code Playgroud)
出现解压的扩展程序图标,如下所示:
但是,当我尝试将其上传到Chrome网上应用店时,图标丢失了,如下所示:
我找不到此问题的任何解决方案。我不知道这是怎么了。