ハース翻訳
by
fmimali
2018-02-16 [2018/02/16 00:25:25]
ハースストーンのデッキを日本語に翻訳します。ポップアップを許可して使ってね
@@ -2,8 +2,8 @@
* @title ハースストーン翻訳
* @description ハースストーンのデッキを日本語に翻訳します。
* @include http://www.hearthpwn.com/decks/*
- * @include http://www.hearthhead.com/decks/*
* @include http://hearthstone.metabomb.net/deck-guides/*
+ * @include http://www.hearthstonetopdecks.com/decks/*
* @license MIT License
* @require jQuery
*/
@@ -29,8 +29,8 @@
var author = $('#content section.user-details ul.user li.name a.tip').text().trim();
var cards = $('table#cards tr td b a');
var arr = [];
- for (i = 0; i < cards.length; i++) {
- card = cards[i];
+ for (var i = 0; i < cards.length; i++) {
+ var card = cards[i];
var c = $(card).attr('data-count');
var n = $(card).text().trim();
arr.push([n, c]);
@@ -43,8 +43,8 @@
var cards = window.HearthHeadData.deck.cards;
var arr = [];
var set = new Set();
- for (i = 0; i < cards.length; i++) {
- card = cards[i];
+ for (var i = 0; i < cards.length; i++) {
+ var card = cards[i];
var n = card.name;
if (set.has(n)) {
arr.push([n, 2]);
@@ -60,16 +60,11 @@
} else if (href.startsWith('http://hearthstone.metabomb.net/deck-guides/')) {
var deck_name = encodeURIComponent($('h1.title').text().trim());
-
- console.log(deck_name);
-
var author = encodeURIComponent($('i.fa-user + span').text());
- console.log(author);
-
var cards = $('div.article-content section table tbody tr td');
var arr = [];
- for (i = 0; i < cards.length; i++) {
- card = cards[i];
+ for (var i = 0; i < cards.length; i++) {
+ var card = cards[i];
var n = $(card).children('span').text().trim();
if (n.length == 0) {
continue;
@@ -78,6 +73,18 @@
arr.push([n, c]);
}
hs2jp(deck_name, author, arr);
+} else if (href.startsWith('http://www.hearthstonetopdecks.com/decks/')) {
+ var deck_name = encodeURIComponent(document.title);
+ var author = encodeURIComponent($('div.player-wrap h2 a').text());
+ var cards = $('ul.deck-class li');
+ var arr = [];
+ for (var i = 0; i < cards.length; i++) {
+ var card = cards[i];
+ var n = $(card).children('a').children('span.card-name').text().trim();
+ var c = $(card).children('span.card-count').text().trim();
+ arr.push([n, c]);
+ }
+ hs2jp(deck_name, author, arr);
} else {
window.open('http://www.hearth.tokyo/not-found');
}
/*
* @title ハースストーン翻訳
* @description ハースストーンのデッキを日本語に翻訳します。
* @include http://www.hearthpwn.com/decks/*
* @include http://hearthstone.metabomb.net/deck-guides/*
* @include http://www.hearthstonetopdecks.com/decks/*
* @license MIT License
* @require jQuery
*/
function hs2jp(deck_name, author, cards) {
var data = 'deck_name=' + deck_name + '&' + 'author=' + author + '&' + 'url=' + window.location.href + '&';
for (i = 0; i < cards.length; i++) {
var n_key = 'n' + i;
var c_key = 'c' + i;
var name = cards[i][0];
var count = cards[i][1];
data = data + n_key + '=' + name + '&';
data = data + c_key + '=' + count + '&';
}
var params = encodeURI(data);
window.open('http://www.hearth.tokyo/translate?' + params);
}
var href = window.location.href;
if (href.startsWith('http://www.hearthpwn.com/decks/')) {
var deck_name = $('h2.deck-title.tip:first').text();
var author = $('#content section.user-details ul.user li.name a.tip').text().trim();
var cards = $('table#cards tr td b a');
var arr = [];
for (var i = 0; i < cards.length; i++) {
var card = cards[i];
var c = $(card).attr('data-count');
var n = $(card).text().trim();
arr.push([n, c]);
}
hs2jp(deck_name, author, arr);
} else if (href.startsWith('http://www.hearthhead.com/decks/')) {
var deck_name = encodeURIComponent(window.HearthHeadData.deck.name);
var author = encodeURIComponent(window.HearthHeadData.deck.username);
var cards = window.HearthHeadData.deck.cards;
var arr = [];
var set = new Set();
for (var i = 0; i < cards.length; i++) {
var card = cards[i];
var n = card.name;
if (set.has(n)) {
arr.push([n, 2]);
set.delete(n);
} else {
set.add(n);
}
}
for (let name of set.values()) {
arr.push([name, 1]);
}
hs2jp(deck_name, author, arr);
} else if (href.startsWith('http://hearthstone.metabomb.net/deck-guides/')) {
var deck_name = encodeURIComponent($('h1.title').text().trim());
var author = encodeURIComponent($('i.fa-user + span').text());
var cards = $('div.article-content section table tbody tr td');
var arr = [];
for (var i = 0; i < cards.length; i++) {
var card = cards[i];
var n = $(card).children('span').text().trim();
if (n.length == 0) {
continue;
}
var c = $(card).text().trim().substr(0, 1);
arr.push([n, c]);
}
hs2jp(deck_name, author, arr);
} else if (href.startsWith('http://www.hearthstonetopdecks.com/decks/')) {
var deck_name = encodeURIComponent(document.title);
var author = encodeURIComponent($('div.player-wrap h2 a').text());
var cards = $('ul.deck-class li');
var arr = [];
for (var i = 0; i < cards.length; i++) {
var card = cards[i];
var n = $(card).children('a').children('span.card-name').text().trim();
var c = $(card).children('span.card-count').text().trim();
arr.push([n, c]);
}
hs2jp(deck_name, author, arr);
} else {
window.open('http://www.hearth.tokyo/not-found');
}
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。