yalb Unlocker

Enables yalb premium buttons

目前為 2020-04-15 提交的版本,檢視 最新版本

// ==UserScript==
// @name         yalb Unlocker
// @namespace    https://gf.qytechs.cn/scripts/400929-yalb-unlocker
// @version      0.3
// @description  Enables yalb premium buttons
// @author       Djamana
// @match        https://*.yalp.io/chords/*
// @grant        none
// @run-at document-body
/*
 * Enables buttons "change speed" without the need to login
 * Enables buttons "loop", "transpose +/-", "Download MIDI" without the need for premium
 *
*/
// ==/UserScript==
'use strict';

// Testpage:
// https://yalp.io/chords/gerhard-schoene-der-laden-efc3
//
// Tested with https://www.yalp.io/js/yalp.min.full.js
// VERSION: 1.18.0  DATE: 2015-09-05


function RestoreButtonIDs() {
debugger
    // We are logged in
    // That will enable speed buttons
    logged = true

    $("#beats_chords_container").height( 1280 )


    var buttons_locked = $("[aria-label].notify-premium")
    console.log ( buttons_locked.length + " premium buttons found." )

    //newID = buttons_locked.getAttribute("data-alert")
    //newID = newID.match ("(?:unlimited-)(.*)(?:-alert)") [1]
    buttons_locked.removeAttr("data-alert" )
    buttons_locked.removeAttr("data-toggle")
    buttons_locked.removeAttr("data-target")
    buttons_locked.removeClass("notify-premium")

    // KEY: "aria-label" : VALUE: new ID and CLASS Name to be added
    var newID_Translator = {
        "Transpose down" : "transpose-minus" ,
        "Transpose up"   : "transpose-plus" ,
        "start tuner"    : "start-tuner" ,
        "generate midi"  : "generate-midi" ,
        "enable loop"    : "loop" ,
        "Print pdf"      : "print-grid"

    }
    var newID = buttons_locked.attr("aria-label")
debugger
    buttons_locked.each( function() {
        try {
            var button_label = $( this ).attr("aria-label")
            newID = newID_Translator[ button_label ]

            // add ID
            this.id = newID

            // add class
            $( this ).addClass(newID)

            console.log ( "NewID: #" + newID + " <= '" + button_label + "'")

        } catch (exception) {
            console.warn('initialize.exception', exception);
        }
    });


//    $('[aria-label="Print pdf"]')
//    .addClass("print-grid")
// Print PDF is not working
// that's the yalb - code this will trigger:
    //$("#print-form [name='token']"     ).val(token)
    //$("#print-form [name='transpose']" ).val(yalpx)
    //$("#print-form"                    ).submit()
// The form 'print-form' is missing




  // Enable Midi-Download
  //    must satisfy $(".generate-midi") to match with yalb handler ".click(function() {..."
//    $('[aria-label="generate midi"]')
//    .addClass("generate-midi")


//    $('[aria-label="start tuner"]')
//      .attr("name","transform")

    //Enable Tuner Handler
    document.getElementById("start-tuner").addEventListener("click", yalpza)



    // it is important to trigger document_ready handler of yalb which will connect eventhandler to the buttons
    if (!$(document).hasClass("ready")) {
        $(document).triggerHandler("ready");
        $(document).addClass("ready")
    }
}

(function() {
    
   // RestoreButtonIDs()
     $( RestoreButtonIDs )

    $( document ).ready(function() {
        console.log( "document loaded" );
    });

    $( window ).on( "load", function() {
        console.log( "window loaded" );

     // Enable Tuner Handler
        document.getElementById("start-tuner").addEventListener("click", yalpza)
    });




     //$(document).ready( RestoreButtonIDs )
    //$(document).on("ready", RestoreButtonIDs)

    // Your code here...
//$("#expand").click(function() {
    //}


})();

QingJ © 2025

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