Greasy Fork

Greasy Fork is available in English.

Copy Lyrics from プチリリ, 歌詞タイム

Selectable lyrics and a button for copying all the lyrics

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Copy Lyrics from プチリリ, 歌詞タイム
// @namespace    http://greasyfork.icu/users/179168
// @version      1.2.1
// @description  Selectable lyrics and a button for copying all the lyrics
// @author       YellowPlus
// @run-at       document-start
// @match        *://petitlyrics.com/lyrics/*
// @match        *://www.kasi-time.com/*
// @grant        none
// @require      https://unpkg.com/ajax-hook/dist/ajaxhook.min.js
// @require      https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    if (document.location.href.match(/.*:\/\/petitlyrics.com\/lyrics\/.*/)) {
        var lyrics;

        $(document).ready(function(){
            $("<button id='copy_button' class='pure-button'>Copy Lyrics</button>").click(()=>{
                $("<textarea id='temp_lyrics'>"+lyrics+"</textarea>").insertAfter("#copy_button");
                $("#temp_lyrics").select();
                document.execCommand("Copy");
                $("#temp_lyrics").remove();
            }).insertBefore("#favorite-status");

            $("<div id='lyrics2' style='font: 12px sans-serif'></div>").insertBefore("#lyrics");
            $("#lyrics").hide();
        });

        // Intercept the data of lyrics
        hookAjax({
            onreadystatechange:function(xhr){
                if (xhr.xhr.responseURL == "https://petitlyrics.com/com/get_lyrics.ajax" && xhr.xhr.responseText !== "") {
                    var array = eval(xhr.xhr.responseText);
                    lyrics = "";
                    array.forEach((data)=>{
                        lyrics += Base64.decode(data.lyrics);
                        lyrics += "\n";
                    });
                    $("#lyrics2").html(lyrics.replace(new RegExp("\n", "g"), "<br>"));
                }
            }
        });

    } else if (document.location.href.match(/.*:\/\/www.kasi-time.com\/.*/)) {
        $(document).ready(function(){
            $("<div class='lyrics_menu'><div class='fontsize'><ul><li style='width: auto; display: block;'>Copy Lyrics</li></ul></div></div>").click(()=>{
                var lyrics = $('#lyrics').html().replace(new RegExp("<br>", "g"), "\n");
                $("<textarea id='temp_lyrics'>"+lyrics+"</textarea>").insertAfter("#lyrics");
                $("#temp_lyrics").select();
                document.execCommand("Copy");
                $("#temp_lyrics").remove();
            }).insertBefore("#lyrics");

            $('body').css('user-select', 'text');
            $('body').css('-moz-user-select', 'text');
            $('body').css('-webkit-user-select', 'text');
            $('body').css('-ms-user-select', 'text');
            $('body').on('copy contextmenu selectstart', (e)=>{
                hi(); // Break the jQuery by an error
            });
        });
    }
})();