hearthpwn2ja

  • /*
     * @title hearthpwn2ja
     * @description translate deck info to japanese on hearthpwn.com
     * @include http://www.hearthpwn.com/decks/*
     * @contributor fmimali http://let.hatelabo.jp/fmimali/let/hLHW-s2jm699
     * @license MIT License https://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // *STRONGLY* recommends Lint/beautify
    //  http://eslint.org/demo/
    //  http://jsbeautifier.org/
    // and ES2015+
    //  https://kangax.github.io/compat-table/es6/
    //  https://caniuse.com/
    //  https://babeljs.io/repl/
    
    (function() {
      'use strict';
    
      var deck_name = document.body.querySelector([
        '#content .deck-title.tip'
      ]).textContent.trim();
    
      var author = document.body.querySelector([
        '#content .user-details .user .name a.tip'
      ]).textContent.trim();
    
      // TBD location.search, URL Object, URLSearchParams
      var queries = [
        'deck_name=' + deck_name,
        'author=' + author,
        'url=' + location.href
      ];
    
      Array.prototype.map.call(document.body.querySelectorAll([
        '#content #cards .col-name a[data-count]'
      ]), function(card) {
        return {
          name: card.textContent.trim(),
          count: card.getAttribute('data-count')
        };
      }).forEach(function(card, idx) {
        queries.push('n' + idx + '=' + card.name);
        queries.push('c' + idx + '=' + card.count);
      });
    
      var search = encodeURI(queries.join('&'));
      window.open('http://www.hearth.tokyo/translate?' + search);
    })();
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2017/05/06 17:42:14 - 2017-05-06
  2. 2017/05/06 08:43:03 - 2017-05-06
  3. 2017/05/06 08:42:58 - 2017-05-06