How to the change color of links to specific file extensions with a userscript? <p>My school website has homework download links and I want to distinguish them by coloring them different colors.<br> EG: Microsoft Word files would be blue and .RTF files would be green.<br> Since I'm new to this none of my scripts are working. </p> <p>My script:</p> <pre><code>// ==UserScript== // @name Homework Help // @namespace http://tampermonkey.net/ // @version 0.1 // @description Color links for different file extensions // @author You // @match (My School Website) // @grant none // ==/UserScript== function getFileExtension(filename) { return filename.split('.').pop(); } (function() { 'use strict'; // Your code here... var links = document.getElementByTagName("a"); var element; for (var i = 0; i &lt; links.lenth(); i++){ element = rtfs[i]; if( getFileExtension(element.href) == "rtf" ){ element.style.color = "green"; } } })(); </code></pre> <p>I tried googling it but found no solution.</p>