Greasy Fork is available in English.

fix edx

Fixing UX problems of Edx

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         fix edx
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Fixing UX problems of Edx
// @author       Yaroslav Shepilov
// @match        https://courses.edx.org/*
// @match        https://inginious-lti.info.ucl.ac.be/*
// @grant        none
// ==/UserScript==

if (window.top === window.self) {

    window.onmessage = function(e){
        if (e.data.includes('"height"') && e.data.includes('"index"')) {
            var message = JSON.parse(e.data);
            var height = message.height;
            var index = message.index;

            //console.log("READ " + e.data);

            if (height > 0) {
                var iframe = document.getElementsByTagName('iframe')[index];

                var currentHeight = iframe.offsetHeight;

                var heightDiff = height - currentHeight;

                if ((heightDiff > 0) || (currentHeight == 800) || (heightDiff < -50)) {
                    iframe.style.height = height + "px";
                }
            }
        }
    };


} else {
    MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
    var currentFrame = window;

    var observer = new MutationObserver(function(mutations, observer) {
        var height = document.body.offsetHeight;

        var index = 0;
        for (var i = 0; i < parent.frames.length; i++) {
            if (parent.frames[i] === currentFrame) {
                index = i;
                break;
            }
        }

        var message = {"index": index, "height": height};
        var jsonMessage = JSON.stringify(message);
        //console.log("WRITE " + jsonMessage);
        window.parent.postMessage(jsonMessage, "https://courses.edx.org/");
    });

    observer.observe(document, {
        subtree: true,
        childList: true
    });
}