Last active
November 18, 2017 16:56
-
-
Save quanon/5541171 to your computer and use it in GitHub Desktop.
「歌詞タイム」(http://www.kasi-time.com/) の歌詞を ○○○ するための Greasemonkey ユーザスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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; | |
// を半角スペースに置換する。 | |
lyrics = lyrics.replace(/ /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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work in Firefox 57 and Greasemonkey 4. Try https://github.com/furyutei/KashiKaikin instead.