My school website has homework download links and I want to distinguish them by coloring them different colors.
EG: Microsoft Word files would be blue and .RTF files would be green.
Since I'm new to this none of my scripts are working.
My script:
// ==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 < links.lenth(); i++){
element = rtfs[i];
if( getFileExtension(element.href) == "rtf" ){
element.style.color = "green";
}
}
})();
I tried googling it but found no solution.