NotebookAutoViewer

Auto view ipython notebook file in github with nbviewer

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Advertisement:

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Advertisement:

// ==UserScript==
// @name         NotebookAutoViewer
// @namespace    https://greasyfork.org/scripts/370056/
// @version      0.1.2
// @description  Auto view ipython notebook file in github with nbviewer
// @author       Yixian Du
// @match        https://*.github.com/*.ipynb
// @license      The MIT License (MIT); http://opensource.org/licenses/MIT
// @grant        none
// ==/UserScript==

var view = function() {
    'use strict';

    if (location.pathname.endsWith('.ipynb')){
        location.assign('https://nbviewer.jupyter.org/github' + location.pathname);
    }
};

function create_view_button() {
    var viewer = document.createElement('span');
    viewer.innerText = 'View';
    viewer.style.color = 'red';
    viewer.addEventListener('click', view, false );
    var path = document.getElementsByClassName('final-path')[0];
    path.parentElement.appendChild(viewer);
};

create_view_button();