NotebookAutoViewer

Auto view ipython notebook file in github with nbviewer

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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();