Seeking script to embed my videos on others' tutorials

7 views
Skip to first unread message

Ellen Spertus

unread,
Dec 24, 2020, 4:34:39 PM12/24/20
to greasemonkey-users
I am a CS professor and would like to embed my instructional videos on pages of the Kotlin Koans tutorial. Could you tell me if there is a script that would facilitate this or if it would be easy to create one?

All of my searches on embedding videos with GreaseMonkey have led to scripts for downloading videos, improving the YouTube experience, etc.

Thanks.

Ellen

Ellen Spertus

unread,
Dec 25, 2020, 6:21:09 PM12/25/20
to greasemonkey-users
I installed TamperMonkey, and it turned out to be pretty trivial to add videos to the tutorial pages. I've appended my script. The video shown isn't mine (yet). I plan to add a dictionary to map from the level and task to the appropriate video.

// ==UserScript==
// @name         Ellen's experiment
// @namespace    http://example.com
// @version      0.1
// @description  show my videos
// @author       Ellen
// @match        https://play.kotlinlang.org/koans/*
// @grant        none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
    'use strict';
    let re = new RegExp('https://play.kotlinlang.org/koans/([^/]+)/([^/]+)/Task.kt');
    var url = window.location.href;
    var groups = re.exec(url);
    var level = groups[1];
    var task = groups[2];
    var d = $("div.editor-content");
    var iframe = $('<iframe>', {
        width: 560,
        height: 315,
        src: "https://www.youtube.com/embed/NIVFgU5f2Rs",
        frameborder: 0
    });
    d.append(iframe);
})();

Reply all
Reply to author
Forward
0 new messages