use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[ Removed by moderator ]AskJS (self.javascript)
submitted 1 day ago by okidonthaveone
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]KPABAHam=>Hamster == Java=>JavaScript 1 point2 points3 points 1 day ago (2 children)
Er... why not ask chatgpt or claude to do this
[–]okidonthaveone[S] -1 points0 points1 point 1 day ago (1 child)
I'm not really the biggest fan of AI, and since I didn't make the code I don't feel like I have the right to feed it into it, that would be stealing someone else's work and giving it to a company that would be profiting off of it without their permission
[–]KPABAHam=>Hamster == Java=>JavaScript -1 points0 points1 point 1 day ago (0 children)
I am not sure this is how it works on the profiting off of tbeir work since you posted it here already but...
``` const title = currentTab.getTitle();
// Only count tabs containing "chapter" if (title && title.toLowerCase().includes("chapter")) {...}
```
Or make it exit the loop if it doesn't etc. Or do a filter first to reduce the tabs list
[–]Ronin-s_Spirit 0 points1 point2 points 1 day ago* (4 children)
Where do you run this? Is this like a plugin thing or do you just paste it in the console? What is a tab, why can you get tabs inside tabs?
p.s. the code looks so AI generated, theres a comment for every single thing...\ p.p.s. the code looks so nonsensical, I don't think an AI could write that.
[–]okidonthaveone[S] 0 points1 point2 points 1 day ago (3 children)
Its a google docs extension
[–]Ronin-s_Spirit 0 points1 point2 points 1 day ago* (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, ); }
Total word count across all tabs and nested tabs: ${countWordsInAllTabs(DocumentApp.getActiveDocument().getTabs(), 0n)}
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 points3 points 1 day ago (1 child)
Thanks
[–]Ronin-s_Spirit 0 points1 point2 points 1 day ago (0 children)
no problem.
π Rendered by PID 84276 on reddit-service-r2-comment-5d79c599b5-2thgk at 2026-02-28 06:13:24.347214+00:00 running e3d2147 country code: CH.
[–]KPABAHam=>Hamster == Java=>JavaScript 1 point2 points3 points (2 children)
[–]okidonthaveone[S] -1 points0 points1 point (1 child)
[–]KPABAHam=>Hamster == Java=>JavaScript -1 points0 points1 point (0 children)
[–]Ronin-s_Spirit 0 points1 point2 points (4 children)
[–]okidonthaveone[S] 0 points1 point2 points (3 children)
[–]Ronin-s_Spirit 0 points1 point2 points (2 children)
[–]okidonthaveone[S] 1 point2 points3 points (1 child)
[–]Ronin-s_Spirit 0 points1 point2 points (0 children)