I'm new in chrome extensions and i'm trying to create a simple extension that close current tab if match an element class.
This is my code in content script:
$(document).ready(function() {
if ($(".watchdogedit").length > 0) {
setTimeout(CLOSECURRENTAB,3000);
}
});
I need the "CLOSECCURENTTAB" function..
Help me!
EDIT:
DONE IT!!
content script:
$(document).ready(function(){
if ($(".watchdogedit").length > 0) {
setTimeout(closeTab, 3000);
}
});
function closeTab() {
chrome.runtime.sendMessage({type: "closeTab"});
}
background script:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.type == "closeTab") {
chrome.tabs.remove(sender.tab.id);
}
}
);