Created
February 17, 2017 02:17
-
-
Save egerlach/32c203a686af8aec388aaa404e66864d to your computer and use it in GitHub Desktop.
Functions to clean up my Tabs Outliner mess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function egerlachClearEmptyWindows() { | |
var windows = document.querySelectorAll('.savedwinNTASC'); | |
for (var i = 0; i < windows.length; i++) { | |
if (windows[i].querySelectorAll('.savedtabNTC').length == 0) { | |
egerlachDeleteTab(windows[i]); | |
} | |
} | |
} | |
function egerlachPruneSavedTabs() { | |
var keepgoing = true; | |
var start = 0; | |
while (keepgoing) { | |
var tabs = document.querySelectorAll('.NTC-tabFrame'); | |
for (var i = start; i < tabs.length; i++) { | |
var url = tabs[i].attributes["href"].value; | |
if (egerlachDeleteAllTabsWithURL(url)) { // Did we delete something? | |
if ((i % 10) == 0) { | |
console.log("Deleted Something! Loop " + i + " of " + tabs.length + "\n" + url); | |
} | |
break; | |
} | |
if ((i+1) == tabs.length) { | |
keepgoing = false; | |
} | |
start++; | |
} | |
} | |
} | |
function egerlachDeleteAllTabsWithURL(url) { | |
var list = document.querySelectorAll('[href="' + url +'"]'); | |
for (var i = 0; i < list.length - 1; i++) { | |
egerlachDeleteTab(list[i]); | |
} | |
return (list.length > 1); | |
} | |
function egerlachDeleteTab(node) { | |
var evt = document.createEvent("CustomEvent"); | |
evt.initCustomEvent("hovering_menu_action_btn_activated", true, true, {"actionId": "deleteAction"}); | |
node.dispatchEvent(evt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment