NotebookAutoViewer

Auto view ipython notebook file in github with nbviewer

// ==UserScript==
// @name         NotebookAutoViewer
// @namespace    https://gf.qytechs.cn/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();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址