TampermonkeyでMy Nintendo Store(Nintendo Switchの購入ページ)を更新するだけのjQueryを作った

2017年9月14日技術

この記事は2017年8月25日に書かれたものです。ご注意ください。

Nintendo Switchが予約形態になったので、供養としてブログに公開します。ってもコレあったところで購入できないほどの激戦だった気がするんですが…

機能は以下の通りです。

  1. 1分ごとにMy Nintendo Storeを自動的に画面更新します。
  2. 更新が成功したら音が鳴り、更新した時間をタイトルに表示します。また画面最下部(購入するボタン)まで移動します。
  3. もし在庫がある場合は更新時とは別の音が鳴り、画面更新が止まります。

ちなみに私はこの機能に加え、PHPを叩いて自分へDMを送る機能を付けてました。

余談ではありますが、My Nintendo StoreのjQueryが読み込めないエラー(例えばサーバ負荷によりサイトが落ちたときとか…)が起きるとリロードできずに詰みます。JavaScriptで書けよ、ってお話ですね(・´з`・)メンド

あとGitHubからはリポジトリごと削除しました。@descriptionの意味が無いね。

ソースコード

// ==UserScript==
// @name         Please switch
// @version      1.0
// @namespace    https://store.nintendo.co.jp/
// @match        https://store.nintendo.co.jp/customize.html
// @author       micelle
// @description  Readme => https://github.com/micelle/PleaseSwitch
// @grant        none
// ==/UserScript==

$(function(){
    $('body').append(
        '<audio id="Bt" src="//cldup.com/35ZlaasnH5.mp3">'+
        '<audio id="Gc" src="//cldup.com/DjXJZR5WQD.mp3">'
    );
    var a=$('#HAC_S_KAYAA .stock').text(),
        b=$('#content h2').text(),
        c=a+b,
        n=new Date(),
        h=n.getHours(),
        m=n.getMinutes(),
        s=n.getSeconds(),
        t=h+':'+m+':'+s+'/'+c,
        B=$('#Bt').get(0),
        G=$('#Gc').get(0);
    B.volume=0.5;
    G.volume=0.5;
    $('title').text(t);
    if(c.match(/(SOLD|エラー)/)){
        B.play();
        setTimeout(function(){location.reload();},ea60);
    }else{
        G.play();
        setTimeout(function(){G.play();},ea60);
    }
    $('html,body').animate({scrollTop:$('#custoize_toCart').offset().top});
});

以下 README.md


PleaseSwitch

My Nintendo Store(Nintendo Switchの購入ページ)を更新するだけのJavaScriptです。
※本ツールは「Tampermonkey」で使用できるJavaScriptです。

It is just JavaScript to update My Nintendo Store (purchase page of Nintendo Switch).
† This is JavaScript available for "Tampermonkey".

説明 (Description)

日本語

  1. 1分ごとにMy Nintendo Storeを自動的に画面更新します。
  2. 更新が成功したら音が鳴り、更新した時間をタイトルに表示します。また画面最下部(購入するボタン)まで移動します。
  3. もし在庫がある場合は更新時とは別の音が鳴り、画面更新が止まります。

English

  1. Automatically refresh "My Nintendo Store" screen every minute
  2. When the update is successful, a sound is heard, and the updated time is displayed in the title. Also move to the bottom of the screen (button to purchase).
  3. If there is stock, a sound different from that at the time of the update sounds, and the screen update stops.

使い方 (Usage)

日本語

  1. Google ChromeにTampermonkeyをインストール。
  2. Tampermonkeyのオプションを起動し、新規スクリプトを作成。
  3. 新規スクリプトのエディターに「PleaseSwitch.js」のコードを記載し、保存します。
  4. My Nintendo Storeを開き、スクリプトが動いているかご確認下さい。

English

  1. Install Tampermonkey in Google Chrome.
  2. Activate the Tampermonkey option and create a new script.
  3. Write the code of "PleaseSwitch.js" in the editor of the new script and save it.
  4. Open My Nintendo Store (JP) and check if the script is running.

その他 (Other)

日本語

  • 本ツールは日本語のみ動作確認をしています。
  • 本ツールにより生じた被害(購入できなかった、エラーが起きた、子供に嫌われた、など)については一切責任を負いません。
  • 音はグラブルのクリック&ガチャを使用しています。

English

  • This tool confirmed the operation only in Japanese.
  • We are not responsible for any damage caused by this tool.(sold out, error occurred, children hated you, and so on)
  • The sound uses GranblueFantasy's "click & gacha".

ライセンス (Licence)

このソフトウェアはMITライセンスでリリースされています。「LICENSE」を参照してください。

This software is released under the MIT License, see "LICENSE".