我正在使用Chrome扩展程序,该扩展程序应有条件地执行操作。 因此,它将调查所有新选项卡的DOM。如果标题标签匹配,则应采取进一步的措施,并将此特定标签隔离在单独的Chrome窗口中。
chrome.tabs.onCreated.addListener(function() {
/*
Multiple Tasks:
1. Check whether title tag matches the CPD Teamcenter title and custom success tab does not exist
2. If yes, trigger three actions:
a. move tab to new Chrome window
b. call external application to hide the window with the isolated tab
c. add custom success tag to identify that this was already processed
*/
const COMPARESTRING = "My Tab Title"
var title = document.getElementsByTagName("title")[0];
alert(title.innerHTML)
if (title.innerHTML === COMPARESTRING) {
return "Match. :-)";
} else {
return "No match. :-(";
}
});
这个非常简单的警报已经不起作用。似乎是在研究background.html而不是新标签的内容。进入新标签的HTML内容上下文需要什么?