0
1

More than 3 years have passed since last update.

よく使うブックマークレット集

Last updated at Posted at 2021-03-10

ブックマークレットひな形

javascript: (function () {
  let input = prompt("何か入力してください。", "foo");
  input = input.replace('a', 'a');  // 通常版
  input = input.replace(/a/g, 'a'); // 正規表現版
  prompt("prompt", input);
})();

よく使うJS部品

/*数値ランダム4桁生成*/
let min = 1000;
let max = 9999;
let randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
/*現在日付yyyymmdd生成*/
const newDate = new Date();
let y = newDate.getFullYear();
let m = ('00' + (newDate.getMonth()+1)).slice(-2);
let d = ('00' + newDate.getDate()).slice(-2);
date = y + '-' + m + '-' + d;

テスト用メールアドレス生成ブックマークレット

javascript: (function () {
    /*現在日付yyyymmdd生成*/
    const newDate = new Date();
    let y = newDate.getFullYear();
    let m = ('00' + (newDate.getMonth()+1)).slice(-2);
    let d = ('00' + newDate.getDate()).slice(-2);
    date = y + '-' + m + '-' + d;

    /*数値ランダム4桁生成*/
    let min = 1000;
    let max = 9999;
    let randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;

    let email = date + "-" + randomNumber + "@co.jp"; /*2021-03-11-8349@co.jp*/
    prompt("prompt", email); 
})();

JSのソースコードを確認する際によく使うサイト

JSソースのコンパイルを確かめるサイト
https://closure-compiler.appspot.com/home

JSソースを整形するサイト
https://lab.syncer.jp/Tool/JavaScript-PrettyPrint/

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1