Today I started building the first real feature for SmoothActions: Copy All Code Blocks.
The goal was simple — click a button in the extension popup and instantly grab every code example from any webpage. ( ̄y▽ ̄)╭ Ohohoho…..
What I built
I wired up the popup UI and wrote the first version of the script that searches the page for and elements. The popup could run scripts on the active tab, and the alert showed up correctly.
The problem
When I tested it on MDN, it didn’t copy the code examples.
Instead, it copied random labels like:
Code
for
condition
continue
break
At first I thought the selector was wrong, but the real issue was that MDN doesn’t use normal or tags for its examples. Some code is inside custom containers, some inside shadow DOM, and some duplicated in the sidebar.
The fix
I rewrote the feature to:
scan normal and blocks
scan MDN‑specific classes like .notranslate and .language-js
scan inside shadow DOM elements
return all code blocks as one combined string
Once I injected the script properly using chrome.scripting.executeScript with a separate file, everything worked. The extension now successfully copies all code examples from the MDN Loops & Iteration page. o(  ̄ ▽ ̄)ブ pluh…
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.