Skip to content

Instantly share code, notes, and snippets.

@quanon
Last active November 18, 2017 16:56
Show Gist options
  • Save quanon/5541171 to your computer and use it in GitHub Desktop.
Save quanon/5541171 to your computer and use it in GitHub Desktop.
「歌詞タイム」(http://www.kasi-time.com/) の歌詞を ○○○ するための Greasemonkey ユーザスクリプト
// ==UserScript==
// @name kashi time
// @namespace quanon
// @include http://www.kasi-time.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
// @grant none
// ==/UserScript==
(function ($) {
var $lyrics = $('#lyrics'),
lyrics = $lyrics.html(),
$link = $('<a>', { href: 'javascript:void(0)', text: '歌詞をコピーする' }),
document,
$textarea;
// &nbsp; を半角スペースに置換する。
lyrics = lyrics.replace(/&nbsp;/g, ' ');
// <br> を改行に置換する。
lyrics = lyrics.replace(/<br>/g, '\n');
// 不要なタグを削除する。
lyrics = lyrics.replace(/<script.*>.*<\/script>/g,'');
lyrics = lyrics.replace(/<noscript.*>.*<\/noscript>/g,'');
// 先頭と末尾の空白を削除する。
lyrics = lyrics.replace(/^\s+/,'');
lyrics = lyrics.replace(/\s+$/,'');
$('.parent_lyrics').append($link);
$link.click(function () {
document = window.open('about:blank', '', 'width=800, height=600').document;
$textarea = $('<textarea>', { onclick: 'this.select();', style: 'width: 100%; height: 100%; border-color: transparent;', text: lyrics });
$textarea.appendTo(document.body);
document.close();
});
})(jQuery);
@seishun
Copy link

seishun commented Nov 18, 2017

Doesn't work in Firefox 57 and Greasemonkey 4. Try https://github.com/furyutei/KashiKaikin instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment