icourse Downloader

get urls of video courses and copy to clipboard

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name          icourse Downloader
// @namespace
// @description   get urls of video courses and copy to clipboard
// @include       https://www.icourse163.org/learn/*
// @version       0.9.0
// @version 0.0.1.20180405103144
// @namespace https://greasyfork.org/users/38547
// ==/UserScript==
(function () {
    'use strict';
	create_button();
	function btn_onclick(){
		var img_addr = document.getElementsByTagName("source")[0].src;
		if (img_addr){
			var patt1 = /http.*(?=\?)/;
            var res = img_addr.match(patt1);
            var obj = document.getElementById("down_video_url");
            obj.value = res;
            obj.type ="";
            obj.select();
            document.execCommand('copy');
            obj.type = "hidden";
            alert('复制完成!');
		}
		else {
			alert("none!");
		}
	}

	function create_button(){
        var ul_tag = document.getElementsByClassName('f-cb')[2];
        var btn = document.createElement("div");
        var t = document.createTextNode("Download");
        btn.appendChild(t);
        btn.style="background-color: green; border: 2px solid green; border-radius: 2px; color: white; padding: 0px 15px; font-size: 14px; cursor: pointer; height: 21px; margin-left: 7px; margin-top: opx; line-height: 21px; font-weight: 500; display: inline-block;";
        btn.setAttribute('id','down_video_btn');
        btn.onclick = btn_onclick;
        ul_tag.appendChild(btn);
        //create input form
        var input1 = document.createElement("input");
        input1.id ="down_video_url";
        input1.value="";
        input1.type="hidden";
        ul_tag.appendChild(input1);
    }


  })();