NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name [NCS] Refresh Course Section
// @description Refresh course content without refreshing full page.
// @version 1.0.1
// @author ClockworkSquirrel
// @match http*://vle.newcollege.ac.uk/course/view.php?id=*
// @require https://code.jquery.com/jquery-3.1.1.min.js
// @run-at document-body
// @grant none
// ==/UserScript==
var refreshTimer = 15; // in seconds
(function() {
'use strict';
$(document).ready(function(){
var pageTitle = $(document.head).find("title").html();
function reloadContents(){
$("section#region-main div.course-content:eq(0) li").each(function(){
var thisContent = $(this);
var thisId = $(this).attr("id");
$(document.head).find("title").html("Reloading content...");
$.get(location.href, function(data){
data = $(data);
var newContent = data.find("li#"+thisId+":eq(0)");
thisContent.html(newContent.html()); //.slideDown();
$(document.head).find("title").html(pageTitle);
}).fail(function(){
location.reload();
});
});
}
$("section#region-main div.course-content:eq(0) li").each(function(){
$(this).contextmenu(function(evt){
var thisContent = $(this);
var thisId = $(this).attr("id");
evt.preventDefault();
$(document.head).find("title").html("Reloading content...");
// thisContent.html("<div class='content'><h3>Refreshing...</h3></div>").slideUp();
//thisContent.slideUp();
$.get(location.href, function(data){
data = $(data);
var newContent = data.find("li#"+thisId+":eq(0)");
thisContent.html(newContent.html()); //.slideDown();
$(document.head).find("title").html(pageTitle);
}).fail(function(){
location.reload();
});
});
});
$("footer#footer div:eq(0)").slideUp();
setInterval(reloadContents, refreshTimer*1000);
});
})();