Skip to content

Instantly share code, notes, and snippets.

@nitinjs
Created April 9, 2025 00:53
Show Gist options
  • Save nitinjs/3c9db137bccaea3c816fc507610b542e to your computer and use it in GitHub Desktop.
Save nitinjs/3c9db137bccaea3c816fc507610b542e to your computer and use it in GitHub Desktop.
Mark questpond videos as watched and view progressbar for videos watched in each section
// ==UserScript==
// @name Questpond: Mark watched
// @namespace http://nitinsawant.com/
// @version 2025-04-03
// @description Mark questpond videos watched
// @author Nitin Sawant
// @match https://questpond.teachable.com/p/questvideos
// @match https://questpond.teachable.com/courses/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=questpond.teachable.com
// @grant GM_addStyle
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
// ==/UserScript==
(function($) {
'use strict';
setTimeout(function(){
var curURL = window.location.pathname;
var curURLIsLecture = curURL.indexOf("/lectures/") !== -1;
if(curURLIsLecture){
var curLectureId = /[^/]*$/.exec(curURL)[0];
Cookies.set(curLectureId, true);
var videoURL = $($("iframe").filter(`[src^="https://player"]`)).prop("src");
$("#lecture_heading").after($("<a>Play</a>").prop("target","_blank").prop("href",videoURL));
}else{
let myCSS=`
.progressbarX {
padding: 1px !important;
}
.progressbarX > div {
background-color: green !important;
height: 25px !important;
margin-left: 3px;
position: absolute;
opacity: 0.5;
}
`;
GM_addStyle(myCSS);
$(".fa-play-circle-o").hide();
$("a.with-chevron").each(function(i,a){
var $a = $(a);
$a.addClass("progressbarX");
$a.prepend($("<div></div>").addClass("progressbarXPercentage"));
});
$(".list-group-item a").each(function(i,a){
var $a = $(a);
var href = $a.prop("href");
var hrefContains = href.indexOf("/lectures/") !== -1;
if(hrefContains){
var lectureId = /[^/]*$/.exec(href)[0];
var $input = $("<input/>").prop("type","checkbox");
$input.prop("id", lectureId);
$input.prop("class","lectureCheckBox");
$input.val(lectureId);
var isChecked = Cookies.get(lectureId);
if(isChecked=="true"){
$input.prop("checked",true);
}
$input.change(function(){
var curLectureId = $(this).val();
Cookies.set(curLectureId, $(this).is(":checked"));
var parentLg = $(this).closest(".list-group");
UpdatePercentage(0, parentLg);
});
$($a.parent("li")).prepend($input);
}
});
function UpdatePercentage(i,lg){
var $li = $($(lg).find(".list-group-item"));
var $lectureCheckBoxes = $($(lg).find(".lectureCheckBox"));
var total = $lectureCheckBoxes.length;
//console.log("TOTAL:"+total);
var checkedBoxes = $($lectureCheckBoxes.filter(":checked")).length;
//console.log("CHECKED:"+checkedBoxes);
var parentContainer = $(lg).closest('div[class^="col-"]');
var $div = $($(parentContainer).find(".progressbarXPercentage"));
var percent = checkedBoxes/total*100;
var pt = 92*percent/100;
//$div.css("width", pt+"%");
$div.animate({ width:pt+"%" });
//console.log($div.css("width"));
}
$(".list-group").each(function(i,lg){
UpdatePercentage(i,lg);
});
}
}, 1500);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment