💨

AtCoderで次の開催回の問題に直接移動するChromeブックマークレット作った

2022/05/08に公開

バックアップ用に残しておく。雑なのでバグってたらすみません🐹

Chromeのサーチエンジンとして登録するとコマンドショートカットできてちょっと便利


ref: https://rawbytz.wordpress.com/2015/11/21/launch-bookmarklets-with-the-keyboard-in-chrome/

次の開催回の問題へ(abc099a -> abc100a)

javascript:(function() { 
  const u = window.location.href.replace(/\d+/g, a => {
      const b = parseInt(a);
      const c = b + 1;
      return c.toString().padStart(3, '0')
  });
  window.open(u, '_self');
})();

前の開催回の問題へ(abc100a -> abc099a)

javascript:(function() { 
  const u = window.location.href.replace(/\d+/g, a => {
      const b = parseInt(a);
      const c = b - 1;
      return c.toString().padStart(3, '0')
  });
  window.open(u, '_self');
})();

自分の回答ページへ飛ぶ

javascript:(function() {
  const l = window.location.href.split('/')[4];
  const jumpUrl = `https://atcoder.jp/contests/${l}/submissions/me`;
  window.open(jumpUrl, '_blank')
})();

追記(2022/05/12)

現在の問題をVSCodeで開く(すでにパス上にファイルが存在していなければならない)

javascript:(function() {
  const l = window.location.href.split('/')[4];
  const arr = window.location.href.split('_');
  const problem = arr[arr.length - 1].toUpperCase();

  const jumpUrl = `vscode://file/Users/harukaeru/Workspace/Algorithms/${l}/${problem}/main.cpp`;
  window.open(jumpUrl, '_self')
})();

Macならこのコマンドが必要。

$ defaults write com.google.Chrome URLAllowlist -array-add 'vscode://*'

参考情報:
https://superuser.com/questions/1481851/disable-chrome-to-ask-for-confirmation-to-open-external-application-everytime

解説を直接開く

javascript:(function() {
  const l = window.location.href.split('/')[4];

  const jumpUrl = `https://img.atcoder.jp/${l}/editorial.pdf`;
  window.open(jumpUrl, '_blank')
})();

Discussion