Amboss No Distractions

Hide all distractions and maximize your reading efficiency in Miamed Amboss. It hides the top / side bar and expand all sections of a card automatically.

当前为 2016-09-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Amboss No Distractions
// @namespace    http://oix.cc/gm
// @description  Hide all distractions and maximize your reading efficiency in Miamed Amboss. It hides the top / side bar and expand all sections of a card automatically.
// @author       Bin Zhang
// @icon         https://amboss.miamed.de/favicon-192x192.png
// @homepageURL  http://oix.cc/amboss
// @version      0.0.2
// @match        https://amboss.miamed.de/library
// @include      /^https?://amboss-miamed-de\.ezproxy\..*/library$/
// @run-at       document-idle
// ==/UserScript==

(function(){

var loadingWatcher;

if (typeof angular !== 'undefined' || typeof angular.element('#LibraryContent').scope() !== 'undefined') {
    setwatcher();
    window.addEventListener("hashchange", setwatcher);
}

function setwatcher(i) {
    if (null !== getParameterByName('xid', '?' + window.location.hash.substring(1))) {
        // only cards set $root.loading, poll loading
        if (!i) i = 20;
        loadingWatcher = setInterval(checkloading, i);
    } else {
        i = 300;
        loadingWatcher = setInterval(function (){
            clearInterval(loadingWatcher);
            loaded();
        }, i);
    }
}
    
function checkloading() {
    console.log('watch');
    console.log(angular.element('#LibraryContent').scope().$root.loading);

    if (angular.element('#LibraryContent').scope().$root.loading !== true) {
        //console.log(typeof angular.element('#LibraryContent').scope().$root.loading);
        clearInterval(loadingWatcher);
        loaded();
    }
}

function loaded () {
    console.log('loaded');
    //console.log($('#LibraryContent').html());

    if ($('#LibraryContent').find('#LibraryList').length > 0) {
        console.log('list');
    } else if (null !== getParameterByName('xid', '?' + window.location.hash.substring(1)) && $('#LibraryContent').find('article.LearningCard').length > 0) {
        console.log('card');
        
        if ($('#amboss-menu').hasClass("move")) {
            $('#amboss-menu').click();
            //angular.element('#amboss-menu').click();
        }
        
        var e = $("#LibraryIndex").find("button.Sidemenu");
        if (e.hasClass("active")) {
            //e.addClass("active");
            LibrarySideMenu.toggleSidemenu();
            //e.hasClass("active") ? (e.removeClass("active"),
            //LibrarySideMenu.closeSidemenu()) : ();
        }
    
        angular.element('#LearningCard').scope().triggerKeyEvent(32);
        // Simulate keyup event
        //var ev = $.Event('keyup');
        //ev.which = 32; // space
        //$('#LearningCard').trigger(ev);
    
        //$('#LibraryContent').find('article.LearningCard').length > 0 && Page.updateElements(1)
    }
}

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

}());