NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name [NCS] Change Name
// @description Change your name on the New College VLE site.
// @version 1.0.3
// @run-at document-start
// @match http*://vle.newcollege.ac.uk/*
// @require https://code.jquery.com/jquery-3.1.1.min.js
// @require https://pastebin.com/raw/nEq3ZVCM
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_addValueChangeListener
// @grant GM_addStyle
// ==/UserScript==
var myName = GM_getValue("setUserName", null);
(function() {
'use strict';
function updateName(){
if (myName === null) return;
var searchTerm;
$("span.usertext").each(function(){
searchTerm = $(this).text().trim();
$(this).parent().html($(this).parent().html().replace(new RegExp(searchTerm, "g"), myName));
});
$("title").text($("title").text().replace(new RegExp(searchTerm, "g"), myName));
}
$("span.usertext").waitUntilExists(updateName);
$(document).ready(updateName);
GM_addStyle("header#header div.header-top{position:fixed;z-index:9999999;width:100%;margin-top:-60px} header#header div.header-main{margin-top:60px}");
GM_registerMenuCommand("Change Name", function(){
GM_setValue("setUserName", prompt("Name"));
});
GM_addValueChangeListener("setUserName", function(name, oldValue, newValue){
myName = newValue;
updateName();
});
})();