yalb Unlocker

Enables yalb premium buttons

目前为 2020-04-16 提交的版本。查看 最新版本

// ==UserScript==
// @name         yalb Unlocker
// @namespace    https://gf.qytechs.cn/scripts/400929-yalb-unlocker
// @version      0.5
// @description  Enables yalb premium buttons
// @author       Djamana
// @match        https://*.yalp.io/chords/*
// @grant        none
// @run-at document-body  //https://tampermonkey.net/documentation.php#_run_at
/*
 * Enables buttons "change speed" without the need to login
 * Enables buttons "loop", "transpose +/-", "Download MIDI", "tuner" without the need for premium
 * "Download PDF", and Upload mp3 is currently not working

 How does this work technically:
 Well nearly all of the yalb-premium functionallity is already there,
 what blocks it from been used is that the buttons at the UI (html-page)
 don't have the correct IDs or Class attribute.
 So later yalb just don't attach the coresponding handler to it.

 So the main mission here is the restore correct IDs or class attributes before
 yalb'S document_ready() event handler is executed.

*/
// ==/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
    // Extend JQuery alittle ...
    $.fn.replaceClass = function (pFromClass, pToClass) {
        return this.removeClass(pFromClass).addClass(pToClass);
    };



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


    var buttons_locked = $(".notify-premium") //[aria-label]

    var premiumItemsCount = buttons_locked.length
    console.log ( premiumItemsCount + " premium buttons found." )
    if (premiumItemsCount <= 4 ) {
        alert( "yalb Unlocker Script - failed. " +
               "Whops just " + premiumItemsCount +
               " ?" +
               "There is something wrong - to less premium items 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);
        }
    });

    // reenable Upload

    // Restore Upload-click
    $(".no-upload-button")
        .replaceClass( "no-upload-button", "upload-button")

    // reenable drop mp3 files
    $('body').addClass("drop")

    // Recreate Upload button
    // TODO: Find out correct upload url (data-url)
    var form = $("<form >"); //id=fileupload
    form
        .append(
        '<input '+
        ' type = "file" '+
        ' id   =  fileupload '+
        ' data-url="//www.yalp.io/submit.php" '+
        ' name="files[]" '+
        '>')
//https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin


//https://www.yalp.io/index3.php
//https://www.yalp.io/lesson/booking_attempt/slot-id/booktutor.idsong?_=1587026316058
//https://www.yalp.io/lesson/pay_with_stripe/e4
//https://www.yalp.io/store_event
//https://www.yalp.io/store_interface_language
//https://www.yalp.io/lesson/get_tutors_availability?user%5Btime_zone%5D=Europe%2FBerlin&language=2&instrument_category=guitar&played_instrument_category=guitar&page=1&from_date=2020-04-16%2000:00&to_date=2020-04-16%2023:59&origin=undefined&tutorid=undefined&_=1587026316059
//https://www.yalp.io/searchemail

        .append('<input type="button" value="action">');
    $('body').append(form);
    //.attr("id","fileupload")


//    $('[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
    var printForm = $(
        "<form " +
        "id     = 'print-form' " +
        "action = 'https://www.yalp.io/submit_yalp.php' " +
        "method = 'post' >"

    ); //id=fileupload
    printForm
        .append('<input type="button" name="token">')
        .append('<input type="button" name="transpose">');
    "submit_yalp.php"
    $('body').append(printForm);




  // 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")


    // 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 RestoreHandlers() {
    //Enable Tuner Handler
    // document.getElementById("start-tuner").addEventListener("click", yalpza)
    $("button#start-tuner").click(yalpza)
    // Note that there are 2 Buttons - one is hidden in the "..." Menu (there is transpose and speed)


     // Enable Tuner Handler
//        var tuner = document.getElementById("start-tuner")//"start-tuner")
//        console.log( tuner.id );
//        debugger
        //tuner.addEventListener("click", yalpza )

    // .. and yes we are logged in
    // so that will lock the "speed buttons"
    //logged = true

}

(function() {
debugger


    // That will be called when the document is ready...
    //$( document ).ready(function() {
     $( RestoreHandlers )


    $( window ).on( "DOMContentLoaded", (event) => {
        console.log('DOM fully loaded and parsed');
    });

    $( document ).ready( (event) =>  {
        console.log( "document loaded" );

        // Restore Buttons IDs and Classes for premium items
        // .. so that yalb will install most of the handler in its document_ready() event handler
        RestoreButtonIDs()

    });

    $( window ).on( "load",  (event) =>  {
        console.log( "window loaded" );
    });

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

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


})();

QingJ © 2025

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