简体   繁体   English

Chrome调试Chrome扩展Javascript

[英]Chrome Debugging Chrome Extension Javascript

I am trying to debug a chrome extension. 我正在尝试调试Chrome扩展程序。 I have opened up the background page in the extension page but I was wondering if there was a way to look at the array type that I have. 我已经在扩展页面中打开了背景页面,但是我想知道是否有一种方法可以查看我拥有的数组类型。

For example, I have the code 例如,我有代码

function main() {
var cells = document.getElementsByClassName('sectionFieldInstructor');
var length = cells.length;
var professors = [];
var profCount = 0;

Where my cells is the teachers in the list. 我的单元格是列表中的老师。 I would like to view which teachers I have in the cells array. 我想查看单元格数组中有哪些老师。

Also, in the inspected page, the teachers name is listed as 另外,在检查页面中,教师姓名列为

<a href="search?mode=search&instructor=TEACHER">A. TEACHER</a><br/>

Would it be affected by that? 会受到影响吗?

Thanks! 谢谢!

You can do that with Chrome developer tools. 您可以使用Chrome开发者工具来做到这一点。 The easiset way is to add 最简单的方法是添加

var cells = document.getElementsByClassName('sectionFieldInstructor');    
    console.log(cells); //Add this line     
var length = cells.length;

Then it will be displayed in your console. 然后它将显示在您的控制台中。 (There is a tab in dev tools called console.) (开发工具中有一个选项卡,称为控制台。)

You can call that function from the console as well by typing: 您还可以从控制台通过键入以下命令来调用该函数:

main();

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM