我正在尝试编写我的第一个chrome扩展程序,它通过url名称用于标签的简单自动排序,但是我在这段代码的末尾得到了“意外的输入结束”。它只是在我添加了onClicked的监听器后才出现。
chrome.browserAction.onClicked.addListener(function apllyOrder(tabs) {
// gets reference array of sorted tabs
reference = sortTabsUrl(tabs);
console.log("Reference array loaded");
// gets amount of pinned tabs to skip them
pinned = tabsPinned(tabs);
console.log("Pinned tabs identified");
//iterates through reference array
for(var i = 0, len = reference.length; i < len; i++){
//iterates through tabs starting from first unpinned tabs
for(var x = pinned, leng = tabs.length; x < leng; x++){
//If the id matches AND reference index is different than current index than it moves the tab
if(tabs[x].id == reference[i].id && x != (i +pinned)){
// tabs is moved based on x(current index) + i(reference index)
chrome.tabs.move(tabs[x].id, i + x)
}
}
}
});
我的清单文件是:
{
"manifest_version": 2,
"name": "Tab Organizer",
"description": "Auto Organizes Tabs",
"version": "1.0",
"background": {
"scripts": ["tabOrganizer.js"],
"persistent": false
},
"permissions": [
"tabs",
"<all_urls>"
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
我想我已经犯了一个愚蠢的错误,因为我是新来的,但提前感谢!