我在编写JS时大量使用console.log进行调试.我正在尝试使用它来编写chrome扩展,但它无法正常工作.这里有一些诡计吗?
popup.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="css/jquery-ui-1.10.0.custom.min.css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body style="width: 200px">
</body>
Run Code Online (Sandbox Code Playgroud)
popup.js
console.log('test1');
$(document).ready(function() {
console.log('test2');
});
Run Code Online (Sandbox Code Playgroud)
这些都不会出现在JS调试器中.
我一直致力于创建我的第一个 chrome 扩展。我已经完成了几个可以在https://developer.chrome.com/extensions/getstarted上找到的示例扩展
如何制作一个扩展程序,以返回 Chrome 中打开的选项卡上所有图像的 url 列表?我已经问过这个问题,但我已经更新了我的问题,希望能让它更清楚。
我知道 javascript 的基础知识,所以我想用该语言创建扩展。这与另一个不同,因为我想获得完整的 url,我想使用简单的 javascript 而不是尝试使用我不知道的 json。
这是我的 manifest.json 文件
{
"name": "Getting Started",
"description": "Get The sources of the images",
"version": "2.0",
"permissions":[
"activeTab",
"tabs"
],
"browser_action":{
"default_title": "Image Source",
"default_popup": "popup.html"
},
"content_scripts":[
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
],
"manifest_version": 2
}
Run Code Online (Sandbox Code Playgroud)
这是我的 content.js 文件
var len = document.images.length;
var imgs = document.images;
var sources = "";
for (var i = 0; i < imgs.length; i++){
sources …Run Code Online (Sandbox Code Playgroud)