I am trying to modify an existing extension (readability) for Chrome. Right now when you save a page with readability it does not close the tab afterwards.
The code in the extension calls a script hosted on their server:
(function(){
rdb.chrome.inject_page_script('/bookmarklet/save.js');
}());
I changed the code to look like this:
(function(){
rdb.chrome.inject_page_script('/bookmarklet/save.js');
chrome.tabs.getSelected( null, function(tab)
{ chrome.tabs.remove(tab.id); return true; });
}());
But it doesn't close the tab or use their function properly. I tried my close tab code alone in the function without their call and it didn't close the tab.
Is there a way to modify their call to close the tab after it does their script to bookmark the page?
I am trying to modify an existing extension (readability) for Chrome. Right now when you save a page with readability it does not close the tab afterwards.
The code in the extension calls a script hosted on their server:
(function(){
rdb.chrome.inject_page_script('/bookmarklet/save.js');
}());
I changed the code to look like this:
(function(){
rdb.chrome.inject_page_script('/bookmarklet/save.js');
chrome.tabs.getSelected( null, function(tab)
{ chrome.tabs.remove(tab.id); return true; });
}());
But it doesn't close the tab or use their function properly. I tried my close tab code alone in the function without their call and it didn't close the tab.
Is there a way to modify their call to close the tab after it does their script to bookmark the page?
Share Improve this question edited Dec 14, 2019 at 4:09 approxiblue 7,12216 gold badges52 silver badges59 bronze badges asked Mar 4, 2012 at 19:31 MichaelMichael 5452 gold badges8 silver badges20 bronze badges2 Answers
Reset to default 3I wouldn't use chromchrome.tabs.getSelected
anymore as it has recently been deprecated. It's remend that you use chrome.tabs.query instead. However, it's also worth mentioning that both of these methods require the tabs permission.
Without looking at the readability extension myself it's hard to determine why your code wasn't being called but I suggest you add debug (e.g. console.log('foo')
) statements to the code in order to determine why that code isn't being reached.
Finally, ensure you are following the correct debugging/development procedures so that you can test your changes easier.
Try:
chrome.tabs.getCurrent(function(tab) {
chrome.tabs.remove(tab.id, function(){});
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745197495a4616165.html
评论列表(0条)