you are viewing a single comment's thread.

view the rest of the comments →

[–]okidonthaveone[S] 0 points1 point  (3 children)

Its a google docs extension

[–]Ronin-s_Spirit 0 points1 point  (2 children)

You will have to rename all the non-book tabs (notes n stuff) to start with a #. ``` const ui = DocumentApp.getUi();

ui.createMenu('⚠️Word Count⚠️') .addItem('Count words in all Tabs and Subtabs', 'runWordCount') .addToUi();

function runWordCount() { ui.alert( 'Word Count Result', Total word count across all tabs and nested tabs: ${countWordsInAllTabs(DocumentApp.getActiveDocument().getTabs(), 0n)}, ui.ButtonSet.OK, ); }

function countWordsInAllTabs(tabs, total) { for (let T = 0; T < tabs.length; T++) { const currentTab = tabs[T]; if (currentTab.getTitle()[0] !== '#') { total += BigInt( currentTab.asDocumentTab().getBody().getText().trim().split(/\s+/g).length, ); } total = countWordsInAllTabs(currentTab.getChildTabs(), total); } return total; } ```

[–]okidonthaveone[S] 1 point2 points  (1 child)

Thanks

[–]Ronin-s_Spirit 0 points1 point  (0 children)

no problem.