<p>I think there's one step between knowledge of HTML/CSS and writing userscripts: knowledge of Developer Tools in Chrome, especially the "Elements" tab. One demonstration students loved seeing was when I "changed" the school website. I simply right-clicked, selected "Inspect", and modified the text. I had to explain to students that I didn't really change the page but that I modified it locally and could "restore" it by refreshing, but it was a lasting demonstration, something they continued to bring up throughout the semester. (This demo also relates to <a href="https://cseducators.stackexchange.com/questions/93/how-can-i-teach-introduce-modern-web-development-in-an-introductory-programming">what I said here about the value of CodePen</a> because you can see your work live.)</p>

<p>Even if there are thousands of LoC, you can get right to where your element is and see the entire path down the "tree" to this element. One fun demonstration is to show students how to "delete" a pop-up from a site or remove an ad or some other obstruction/intrusion by inspecting the page to "search and destroy" what you want to get rid of.</p>

<p>Consider Bloom's taxonomy here. You have an opportunity to move up the ladder as follows: <code>Comprehension/Knowledge (basic HTML/CSS) --&gt; Application/Analysis (Developer Tools/Inspect) --&gt; Synthesis/Creation (Userscripts)</code>. This progression is important to keep in mind so as to adequately prepare students for creating something meaningful of their own, and I think the study of how popular sites are structured will aid in this process. Hacking away for fun at a page may give them an idea for what would be cool to script themselves.</p>

<p>The teaching benefit is such that you can unleash students' seemingly unlimited creativity as they write helpful scripts for their own personal browsing experience. Yet, as you note, it does not come without challenges and must be approached methodically.</p>

CC BY-SA 4.0
2019-02-25T05:12:33.330Z
Wonderful! I'd just like to point out that the developer tools are **not specific to Chrome**. Firefox and Safari both have quite capable dev tools as well (I don't have experience with any other browsers). Let's not forget that Chrome isn't the only browser!
SilverWolf
CC BY-SA 3.0
2017-05-30T07:01:49.377Z
2017-05-30T07:01:49.377Z
Peter
<p>I've thought about using userscripts as a tool, or even a foundation, for teaching front-end web development as well but haven't had an opportunity to try it out yet (I'll update this when I do!), so please take my musings with a grain of salt.</p>
<h2>The &quot;power user&quot; vs &quot;user&quot; mentality</h2>
<p>Userscripts are fundamentally a productivity tool. They offer organization, standardization, convenience and automation for power users. These benefits aren't likely obvious to entry-level programmers, especially younger audiences who are generally happy interfacing with technology in a very direct, surface level manner and probably won't see a pressing need to add a usability feature to, say, avoid repetitive tasks in their favorite app.</p>
<p>While obvious educational opportunity exists here, I'd use caution to avoid over-emphasizing tools and concepts that are really geared towards programmers and power users rather than application users. It takes time for programming students to switch to a hacker/power user/automator mindset and appreciate things like git, design patterns, memory management, databases and so forth. I'd put userscripts in this bucket as well.</p>
<h2>Teaching browser development tools is usually enough</h2>
<p>When most of us teach broswer developer tools to entry-level programmers, we usually do fun stuff like the classic day-one activity of &quot;hacking&quot; Wikipedia or Google by changing article headers or search results. Although there's subtle practical power here that userscripts help harness, this is mostly a fun and zero-installation way to get them used to HTML, CSS and JS (what they are/do, what do they look like) and build familiarity with the tool they'll soon be using to debug their own sites.</p>
<p>It's powerful to show students that they can easily look at and even manipulate the source that powers the websites they're visiting. One of the amazing aspects of the web is that the source is right there in front of you! There's a big &quot;wow&quot; factor there.</p>
<p>But how far does the magic carry a curriclum? It's probably pretty short-lived, and a deep dive into the console has diminishing returns for early programmers. Students will want to get on to making their own app than messing endlessly with other people's apps, and for good reason. One must <em>write</em> HTML, CSS and JS from scratch to understand it, and no amount of developer tools offers this. For more experienced programmers, this is less of an issue.</p>
<h2>Who's the audience?</h2>
<p>As with any educational tool, audience is everything. If the audience is a bunch of adults that are tired of repetitive clicking at their jobs, userscripting seems like a great way to empower and engage them without much effort.</p>
<p>For younger audiences, I'd try for creative projects. Userscripts can automate playing online games like <a href="https://en.wikipedia.org/wiki/Cookie_Clicker" rel="nofollow noreferrer">cookie clicker</a>, manipulating a Discord chat in real-time, or tweeting responses to certain messages automatically. It'd be interesting to try to make online art with userscripts by applying radical and surprising alterations to web pages.</p>
<p>Even if these sort of projects are cool, it's not clear that anything more than copy-pasting code (written in, say, Notepad++ or an online editor) into the console is necessary.</p>
<p><a href="https://en.wikipedia.org/wiki/Bookmarklet" rel="nofollow noreferrer">Bookmarklets</a> also offer persistence and relative ease of operation without a full-fledged userscript, with the downside that they're inelegant and more restrictive. I recommend The Coding Train's <a href="https://thecodingtrain.com/learning/programming-with-text/11.2-bookmarklets.html" rel="nofollow noreferrer">bookmarklet challenge</a>. Interestingly, I don't see any userscript content (or <a href="https://github.com/CodingTrain/Rainbow-Topics/issues" rel="nofollow noreferrer">suggestions</a> that Daniel cover userscripts) from them.</p>
<p>A userscript-focused curriculum seems like a better fit for an audience of programmers who know HTML5 basics, have made a few basic sites, games and apps and want to apply their skills to something new and interesting.</p>
<hr />
<h3>Advantages</h3>
<p>Some advantages I can see of teaching JS (and HTML/CSS) through userscripts:</p>
<ul>
<li>Environment set up is easy and userscript manager extensions like <a href="https://www.tampermonkey.net/" rel="nofollow noreferrer">Tampermonkey</a> have a built-in editor</li>
<li>The coding is approachable, with caveats below</li>
<li>Students work with other people's code, develop an appreciation for the complexity of real websites and gain exposure to many useful concepts</li>
<li>It's empowering to be able to customize popular websites</li>
<li>There are plenty of opportunities for creative projects</li>
<li>Because the site is already created, there's less of a feeling of blank canvas or intimidation of building a huge project from the ground up to make something cool and useful</li>
<li>Students can explore existing scripts</li>
<li>It's rather unorthodox, so your curriculum stands out from the crowd. It could catch on like <a href="https://automatetheboringstuff.com/" rel="nofollow noreferrer">Automate the Boring Stuff with Python</a>, an incredible book that manages to teach programming through a productivity lens in a way that's accessible and fun for nearly all audiences with basic computer literacy.</li>
</ul>
<h3>Disadvantages</h3>
<ul>
<li>Could be dry and de-motivating for the wrong audience; userscripts tend to be productivity/tooling -centric</li>
<li>Potentially too much reliance on the console environment at the expense of obviously-beneficial greenfield projects built by hand (inexperienced students will need to do those anyway -- userscripts aren't a drop-in substitute)</li>
<li>Not really a key skill, writing userscripts is always a sideline even among web programmers</li>
<li>Possibly diminished sense of ownership relative to a greenfield app project</li>
<li>Websites can change a lot and have hidden or nondeterministic complexities like <a href="https://en.wikipedia.org/wiki/A/B_testing" rel="nofollow noreferrer">A/B testing</a> that break userscripts (and your assignments) easily</li>
<li>As suggested by OP, the massive size and complexity of sites can be intimidating, although dev tools does a great job of handling minified, modern production sites thanks to the live interactive virtual DOM tree</li>
<li>Although the coding isn't typically advanced (running <code>document.querySelector()</code> and calling <code>.click()</code> or setting style attributes, injecting <code>innerHTML</code>, etc), writing userscripts can easily slide into a plethora of advanced concepts like asynchrony, event listener behavior, DOM loading and resource requests, element visibility minutiae and countless other things an experienced programmer takes for granted or can research in situ, but are sometimes prohibitive to introduce to beginners.</li>
</ul>
<hr />
<h2>Project idea brainstorm</h2>
<h3>&quot;Fun&quot; project ideas for &quot;kids&quot; (some adults qualify)</h3>
<ul>
<li>&quot;Prank&quot; a site to change the behavior in a subtle way, like making buttons run away from the mouse when the user tries to click on them. I've done these with kids and they enjoy showing the sites to their parents, teachers and friends.</li>
<li>Expanding on the Twitter/Discord userscript idea: you can add a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver" rel="nofollow noreferrer"><code>MutationObserver</code></a> or poll the message feed. When certain messages appear, the script can type a response. As a simple idea, the response could be a quote or gif pulled from an API, or could perform simple commands like &quot;add two numbers&quot;. This can create pretty exciting emergent behavior for students with multiple bots talking to each other. (Yes, you could write a legitimate Discord bot, but this achieves much of the same result with less effort)</li>
<li>Create animations using <a href="https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame" rel="nofollow noreferrer"><code>requestAnimationFrame</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout" rel="nofollow noreferrer"><code>setTimeout</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval" rel="nofollow noreferrer"><code>setInterval</code></a>. Options are endless: make page text scroll like the old <code>&lt;marquee&gt;</code>, make background colors morph to make psychedelic patterns (seizure warning), add an animation trail to the mouse cursor, stretch page images comedically...</li>
<li>Think creatively: manipulate Wikipedia text to create a <a href="https://en.wikipedia.org/wiki/Mad_Libs" rel="nofollow noreferrer">mad libs</a> story, <a href="https://blackoutpoetry.net/" rel="nofollow noreferrer">blackout poetry</a> or interactive fiction narrative.</li>
<li>HTML5 audio is wild. For starters, check out the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API" rel="nofollow noreferrer">Web Speech API</a>. Students create a userscript which reads the contents of a website or lets them type into a website by voice.</li>
<li>Pointless fun: add rainbow color schemes to serious government websites, replace depressing images in the news with unicorns, automatically trigger clicks on links to browse sites programmatically, for example to play <a href="https://www.patheos.com/blogs/religionprof/2017/12/seven-steps-jesus.html" rel="nofollow noreferrer">seven steps to Jesus</a> (probably use something other than Jesus, but the idea applies), etc.</li>
<li>Use a machine learning library to analyze text sentiment on a page.</li>
<li>Use a machine learning library to analyze a video stream and manipulate the page, for example, <a href="https://realless.glitch.me/" rel="nofollow noreferrer">change background when you blink</a>.</li>
<li>More pointless fun: <a href="https://github.com/chinchang/code-blast-codemirror" rel="nofollow noreferrer">Make text shake when you type</a> or add physics to webpages using Matter.js.</li>
</ul>
<p>As with any technology project, there's a lot of potential for abuse here, so it's important to keep it fun and remind students about not spamming, being nice online and not accidentally deleting a profile or sending their bank account balance to a phisher because of a script run amok.</p>
<h3>&quot;Serious&quot; project ideas for &quot;adults&quot; (some kids qualify)</h3>
<ul>
<li>All things API: fetch data from somewhere and put it into something. For example, hovering over a word with the mouse fetches a dictionary definition that appears in a tooltip.</li>
<li>Changing color schemes to improve usability on a site</li>
<li>Macros for repetitive tasks and accessing features buried in menus</li>
<li>Use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" rel="nofollow noreferrer">localStorage</a> or even a backend app with a database (could be hosted on <a href="https://glitch.com/" rel="nofollow noreferrer">glitch</a> for free) to remember specific actions taken on a page, for example, keep track of songs listened to on <a href="https://bandcamp.com/" rel="nofollow noreferrer">Bandcamp</a></li>
<li>Instead of wasting time watching the <a href="https://cdn-images-1.medium.com/max/1600/1*99yygXrRR8ix1wDOsdjLKA.gif" rel="nofollow noreferrer">Gmail/Hotmail logo</a> when booting up email, show news headlines, a random fact or random Wikipedia article</li>
<li>Injecting <a href="https://codemirror.net/" rel="nofollow noreferrer">Codemirror</a> into textareas to use, say, <a href="https://userscripts.glitch.me/userscripts/vimify.user.js" rel="nofollow noreferrer">Vim keybindings</a></li>
<li>Improving page load times by blocking resource requests</li>
<li>Automatically dismissing annoying pop ups</li>
<li>Programmatically importing data into forms</li>
<li>Scraping data that isn't easily copy-pasteable and without writing a back-end app</li>
<li>Filtering unwanted posts and distracting features in social media streams</li>
<li>Did I mention <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API" rel="nofollow noreferrer">web audio</a>?</li>
</ul>
<p>It turns out these are basically console/bookmarklet projects that aren't exactly essential to userscripting per se (and in many cases not inherent to the console environment), although userscripting certainly can help facilitate delivery.</p>
<p>Also, much of these ideas are already implemented as bookmarklets, pre-written userscripts or <a href="https://en.wikipedia.org/wiki/Browser_extension" rel="nofollow noreferrer">browser extensions</a> (extensions are another thing worth considering for this sort of curriculum). It's OK to reinvent the wheel in the interests of learning and having fun.</p>
<hr />
<p>To summarize, userscripts are an interesting tool and there's definitely plenty of potential for educational use. A strong curriculum targeted to the right audience could offer an original angle to learning programming, but at the end of the day, the focus would really be on manipulating sites through the console and developer tools, with userscripts a handy way to streamline that process rather than an end in and of themselves.</p>

CC BY-SA 4.0
2021-07-30T20:10:35.797Z
2021-07-30T23:36:38.533Z
2021-07-30T23:36:38.533Z
ggorlen
<blockquote>
<h1>What is a User Script?</h1>
<p>Useful tasks like improving layout, fixing bugs, automating common tasks and adding new functions can all be done by userscripts. More complicated userscripts can create mash-ups by combining information from different websites or embedding new data into a web page, e.g. to add reviews or price comparisons to a shopping website.</p>
<p>Source: <a href="https://github.com/OpenUserJs/OpenUserJS.org/wiki/Userscript-beginners-HOWTO#what-is-a-user-script" rel="nofollow noreferrer">https://github.com/OpenUserJs/OpenUserJS.org/wiki/Userscript-beginners-HOWTO#what-is-a-user-script</a></p>
<p>A user script is programming that modifies the appearance or behavior of an application. A user script for a Web site, for example, can customize the way that content will display in the host browser.</p>
<p>Source: <a href="http://whatis.techtarget.com/definition/user-script" rel="nofollow noreferrer">http://whatis.techtarget.com/definition/user-script</a></p>
</blockquote>
<p>I'm planning out a curriculum for my web development class next year, and based on <a href="https://cseducators.stackexchange.com/questions/172/how-can-i-maintain-interest-in-front-end?noredirect=1#comment429_172">a comment</a> by <a href="https://cseducators.stackexchange.com/users/41/sean-houlihane">Sean Houlihane</a> I realized that userscripts could be useful as a teaching tool so that students can see results immediately, and actually make use of their front-end skills as soon as they know the basics.</p>
<p>Before I would introduce my students to this, they'd have to understand the basics of HTML/CSS/JS. If my students already have basic knowledge, how useful could userscripts be as a teaching tool and what are some ways in which I could use them?</p>
<p>Some potential issues that I foresee are:</p>
<ul>
<li>It'll be complicated. For a major website, the stylesheet could be thousand LoC.</li>
<li>Minification. Especially for JS. It makes it very challenging to modify existing code if it has been minified. Even when re-prettified, it can still have terrible variable and method naming.</li>
</ul>
<p>Working around these issues, what are some uses for userscripts as a teaching tool and in the classroom?</p>

<lesson-ideas><web-development><front-end>
Are userscripts a good teaching tool?
# Are userscripts a good teaching tool?

(Asked by: username_0 on 2017-05-30)

> # What is a User Script?
>
> Useful tasks like improving layout, fixing bugs, automating common tasks and adding new functions can all be done by userscripts. More complicated userscripts can create mash-ups by combining information from different websites or embedding new data into a web page, e.g. to add reviews or price comparisons to a shopping website.
>
> Source: <https://github.com/OpenUserJs/OpenUserJS.org/wiki/Userscript-beginners-HOWTO#what-is-a-user-script>
>
> A user script is programming that modifies the appearance or behavior of an application. A user script for a Web site, for example, can customize the way that content will display in the host browser.
>
> Source: <http://whatis.techtarget.com/definition/user-script>

I'm planning out a curriculum for my web development class next year, and based on [a comment](https://cseducators.stackexchange.com/questions/172/how-can-i-maintain-interest-in-front-end?noredirect=1#comment429_172) by [Sean Houlihane](https://cseducators.stackexchange.com/users/41/sean-houlihane) I realized that userscripts could be useful as a teaching tool so that students can see results immediately, and actually make use of their front-end skills as soon as they know the basics.

Before I would introduce my students to this, they'd have to understand the basics of HTML/CSS/JS. If my students already have basic knowledge, how useful could userscripts be as a teaching tool and what are some ways in which I could use them?

Some potential issues that I foresee are:

* It'll be complicated. For a major website, the stylesheet could be thousand LoC.
* Minification. Especially for JS. It makes it very challenging to modify existing code if it has been minified. Even when re-prettified, it can still have terrible variable and method naming.

Working around these issues, what are some uses for userscripts as a teaching tool and in the classroom?

**Tags:** lesson-ideas, web-development, front-end


---

## 2 answers

### Answer by username_3 on 2021-07-30. Score: 1 | Accepted answer

I've thought about using userscripts as a tool, or even a foundation, for teaching front-end web development as well but haven't had an opportunity to try it out yet (I'll update this when I do!), so please take my musings with a grain of salt.

## The "power user" vs "user" mentality

Userscripts are fundamentally a productivity tool. They offer organization, standardization, convenience and automation for power users. These benefits aren't likely obvious to entry-level programmers, especially younger audiences who are generally happy interfacing with technology in a very direct, surface level manner and probably won't see a pressing need to add a usability feature to, say, avoid repetitive tasks in their favorite app.

While obvious educational opportunity exists here, I'd use caution to avoid over-emphasizing tools and concepts that are really geared towards programmers and power users rather than application users. It takes time for programming students to switch to a hacker/power user/automator mindset and appreciate things like git, design patterns, memory management, databases and so forth. I'd put userscripts in this bucket as well.

## Teaching browser development tools is usually enough

When most of us teach broswer developer tools to entry-level programmers, we usually do fun stuff like the classic day-one activity of "hacking" Wikipedia or Google by changing article headers or search results. Although there's subtle practical power here that userscripts help harness, this is mostly a fun and zero-installation way to get them used to HTML, CSS and JS (what they are/do, what do they look like) and build familiarity with the tool they'll soon be using to debug their own sites.

It's powerful to show students that they can easily look at and even manipulate the source that powers the websites they're visiting. One of the amazing aspects of the web is that the source is right there in front of you! There's a big "wow" factor there.

But how far does the magic carry a curriclum? It's probably pretty short-lived, and a deep dive into the console has diminishing returns for early programmers. Students will want to get on to making their own app than messing endlessly with other people's apps, and for good reason. One must *write* HTML, CSS and JS from scratch to understand it, and no amount of developer tools offers this. For more experienced programmers, this is less of an issue.

## Who's the audience?

As with any educational tool, audience is everything. If the audience is a bunch of adults that are tired of repetitive clicking at their jobs, userscripting seems like a great way to empower and engage them without much effort.

For younger audiences, I'd try for creative projects. Userscripts can automate playing online games like [cookie clicker](https://en.wikipedia.org/wiki/Cookie_Clicker), manipulating a Discord chat in real-time, or tweeting responses to certain messages automatically. It'd be interesting to try to make online art with userscripts by applying radical and surprising alterations to web pages.

Even if these sort of projects are cool, it's not clear that anything more than copy-pasting code (written in, say, Notepad++ or an online editor) into the console is necessary.

[Bookmarklets](https://en.wikipedia.org/wiki/Bookmarklet) also offer persistence and relative ease of operation without a full-fledged userscript, with the downside that they're inelegant and more restrictive. I recommend The Coding Train's [bookmarklet challenge](https://thecodingtrain.com/learning/programming-with-text/11.2-bookmarklets.html). Interestingly, I don't see any userscript content (or [suggestions](https://github.com/CodingTrain/Rainbow-Topics/issues) that Daniel cover userscripts) from them.

A userscript-focused curriculum seems like a better fit for an audience of programmers who know HTML5 basics, have made a few basic sites, games and apps and want to apply their skills to something new and interesting.

---

### Advantages

Some advantages I can see of teaching JS (and HTML/CSS) through userscripts:

* Environment set up is easy and userscript manager extensions like [Tampermonkey](https://www.tampermonkey.net/) have a built-in editor
* The coding is approachable, with caveats below
* Students work with other people's code, develop an appreciation for the complexity of real websites and gain exposure to many useful concepts
* It's empowering to be able to customize popular websites
* There are plenty of opportunities for creative projects
* Because the site is already created, there's less of a feeling of blank canvas or intimidation of building a huge project from the ground up to make something cool and useful
* Students can explore existing scripts
* It's rather unorthodox, so your curriculum stands out from the crowd. It could catch on like [Automate the Boring Stuff with Python](https://automatetheboringstuff.com/), an incredible book that manages to teach programming through a productivity lens in a way that's accessible and fun for nearly all audiences with basic computer literacy.

### Disadvantages

* Could be dry and de-motivating for the wrong audience; userscripts tend to be productivity/tooling -centric
* Potentially too much reliance on the console environment at the expense of obviously-beneficial greenfield projects built by hand (inexperienced students will need to do those anyway -- userscripts aren't a drop-in substitute)
* Not really a key skill, writing userscripts is always a sideline even among web programmers
* Possibly diminished sense of ownership relative to a greenfield app project
* Websites can change a lot and have hidden or nondeterministic complexities like [A/B testing](https://en.wikipedia.org/wiki/A/B_testing) that break userscripts (and your assignments) easily
* As suggested by OP, the massive size and complexity of sites can be intimidating, although dev tools does a great job of handling minified, modern production sites thanks to the live interactive virtual DOM tree
* Although the coding isn't typically advanced (running `document.querySelector()` and calling `.click()` or setting style attributes, injecting `innerHTML`, etc), writing userscripts can easily slide into a plethora of advanced concepts like asynchrony, event listener behavior, DOM loading and resource requests, element visibility minutiae and countless other things an experienced programmer takes for granted or can research in situ, but are sometimes prohibitive to introduce to beginners.

---

## Project idea brainstorm

### "Fun" project ideas for "kids" (some adults qualify)

* "Prank" a site to change the behavior in a subtle way, like making buttons run away from the mouse when the user tries to click on them. I've done these with kids and they enjoy showing the sites to their parents, teachers and friends.
* Expanding on the Twitter/Discord userscript idea: you can add a [`MutationObserver`](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) or poll the message feed. When certain messages appear, the script can type a response. As a simple idea, the response could be a quote or gif pulled from an API, or could perform simple commands like "add two numbers". This can create pretty exciting emergent behavior for students with multiple bots talking to each other. (Yes, you could write a legitimate Discord bot, but this achieves much of the same result with less effort)
* Create animations using [`requestAnimationFrame`](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame), [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout) and [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval). Options are endless: make page text scroll like the old , make background colors morph to make psychedelic patterns (seizure warning), add an animation trail to the mouse cursor, stretch page images comedically...
* Think creatively: manipulate Wikipedia text to create a [mad libs](https://en.wikipedia.org/wiki/Mad_Libs) story, [blackout poetry](https://blackoutpoetry.net/) or interactive fiction narrative.
* HTML5 audio is wild. For starters, check out the [Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API). Students create a userscript which reads the contents of a website or lets them type into a website by voice.
* Pointless fun: add rainbow color schemes to serious government websites, replace depressing images in the news with unicorns, automatically trigger clicks on links to browse sites programmatically, for example to play [seven steps to Jesus](https://www.patheos.com/blogs/religionprof/2017/12/seven-steps-jesus.html) (probably use something other than Jesus, but the idea applies), etc.
* Use a machine learning library to analyze text sentiment on a page.
* Use a machine learning library to analyze a video stream and manipulate the page, for example, [change background when you blink](https://realless.glitch.me/).
* More pointless fun: [Make text shake when you type](https://github.com/chinchang/code-blast-codemirror) or add physics to webpages using Matter.js.

As with any technology project, there's a lot of potential for abuse here, so it's important to keep it fun and remind students about not spamming, being nice online and not accidentally deleting a profile or sending their bank account balance to a phisher because of a script run amok.

### "Serious" project ideas for "adults" (some kids qualify)

* All things API: fetch data from somewhere and put it into something. For example, hovering over a word with the mouse fetches a dictionary definition that appears in a tooltip.
* Changing color schemes to improve usability on a site
* Macros for repetitive tasks and accessing features buried in menus
* Use [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) or even a backend app with a database (could be hosted on [glitch](https://glitch.com/) for free) to remember specific actions taken on a page, for example, keep track of songs listened to on [Bandcamp](https://bandcamp.com/)
* Instead of wasting time watching the [Gmail/Hotmail logo](https://cdn-images-1.medium.com/max/1600/1*99yygXrRR8ix1wDOsdjLKA.gif) when booting up email, show news headlines, a random fact or random Wikipedia article
* Injecting [Codemirror](https://codemirror.net/) into textareas to use, say, [Vim keybindings](https://userscripts.glitch.me/userscripts/vimify.user.js)
* Improving page load times by blocking resource requests
* Automatically dismissing annoying pop ups
* Programmatically importing data into forms
* Scraping data that isn't easily copy-pasteable and without writing a back-end app
* Filtering unwanted posts and distracting features in social media streams
* Did I mention [web audio](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API)?

It turns out these are basically console/bookmarklet projects that aren't exactly essential to userscripting per se (and in many cases not inherent to the console environment), although userscripting certainly can help facilitate delivery.

Also, much of these ideas are already implemented as bookmarklets, pre-written userscripts or [browser extensions](https://en.wikipedia.org/wiki/Browser_extension) (extensions are another thing worth considering for this sort of curriculum). It's OK to reinvent the wheel in the interests of learning and having fun.

---

To summarize, userscripts are an interesting tool and there's definitely plenty of potential for educational use. A strong curriculum targeted to the right audience could offer an original angle to learning programming, but at the end of the day, the focus would really be on manipulating sites through the console and developer tools, with userscripts a handy way to streamline that process rather than an end in and of themselves.


---

### Answer by username_1 on 2017-05-30. Score: 3

I think there's one step between knowledge of HTML/CSS and writing userscripts: knowledge of Developer Tools in Chrome, especially the "Elements" tab. One demonstration students loved seeing was when I "changed" the school website. I simply right-clicked, selected "Inspect", and modified the text. I had to explain to students that I didn't really change the page but that I modified it locally and could "restore" it by refreshing, but it was a lasting demonstration, something they continued to bring up throughout the semester. (This demo also relates to [what I said here about the value of CodePen](https://cseducators.stackexchange.com/questions/93/how-can-i-teach-introduce-modern-web-development-in-an-introductory-programming) because you can see your work live.)

Even if there are thousands of LoC, you can get right to where your element is and see the entire path down the "tree" to this element. One fun demonstration is to show students how to "delete" a pop-up from a site or remove an ad or some other obstruction/intrusion by inspecting the page to "search and destroy" what you want to get rid of.

Consider Bloom's taxonomy here. You have an opportunity to move up the ladder as follows: `Comprehension/Knowledge (basic HTML/CSS) --> Application/Analysis (Developer Tools/Inspect) --> Synthesis/Creation (Userscripts)`. This progression is important to keep in mind so as to adequately prepare students for creating something meaningful of their own, and I think the study of how popular sites are structured will aid in this process. Hacking away for fun at a page may give them an idea for what would be cool to script themselves.

The teaching benefit is such that you can unleash students' seemingly unlimited creativity as they write helpful scripts for their own personal browsing experience. Yet, as you note, it does not come without challenges and must be approached methodically.

> **Comments:**
> **username_2**: Wonderful! I'd just like to point out that the developer tools are **not specific to Chrome**. Firefox and Safari both have quite capable dev tools as well (I don't have experience with any other browsers). Let's not forget that Chrome isn't the only browser!  

---

