Greasy Fork

Greasy Fork is available in English.

Songsterr Print-Enabler

Enable printing at songsterr.com

当前为 2019-10-24 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Songsterr Print-Enabler
// @namespace    http://greasyfork.icu/de/scripts/369383-songsterr-print-enabler
// @version      0.5
// @description  Enable printing at songsterr.com
// @author       Guitar Hero
// @grant        none
// @include *songsterr.com*
// @include songsterr.com*
// @include *songsterr.com
// @include songsterr.com
// @include www.songsterr.com*
// @include http://songsterr.com/*
// @include http://*.songsterr.com/*

// ==/UserScript==

(function() {
    'use strict';

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }
    
    // Remove nag screens
    function removeNagScreens() {
        addGlobalStyle('section section:not(#tablature) { display: none !important; }');
        addGlobalStyle('header a[target="_blank"] { display: none !important; }');
    }

    // Show tabs
    function showTabsOnPrintView() {
        addGlobalStyle('#root #tablature svg:not(:first-child) { display: block !important; }');
        addGlobalStyle('@media print { #root #tablature svg g[data-label=cursor] { display: none !important; } }');
    }

    // Enable print button
    function enablePrintButton() {
        try {
            addGlobalStyle('.enabler-print > div[role=dialog] { display: none !important; }');
            
            var printElement = document.querySelector('#print-title-id').parentNode;
            printElement.parentNode.parentNode.classList.add('enabler-print');
            printElement.onclick = function(){window.print();};
        } catch(ex) {
            console.log("error enabling print button: " + ex);
        }
    }

    function enableAll() {
        removeNagScreens();
        showTabsOnPrintView();
        enablePrintButton();
    }

    function registrateOnLocationChange() {
        var pushState = history.pushState;
        history.pushState = function () {
            var changedUrl = arguments[2];
            pushState.apply(history, arguments);
            enableAll();
        };
    }
    registrateOnLocationChange();
    enableAll();
})();