LoginSignup
3
3

More than 1 year has passed since last update.

稀に使うコード集

Last updated at Posted at 2022-10-06

稀に使うコード集

ページ内のリンクアドレスを一括コピーします。

※googleやYOUTUBEページではコピーメソッドが使用できないようです。

Chromeコンソール画面にて
copy([...document.querySelectorAll("a")].map(e=>e.href).join("\n"));
//copy(Odocument.querySelectorAll("a")).map(key=>document.querySelectorAll("a")[key].href).join("\n"));

ページ内の画像アドレスを一括コピーします。

※googleやYOUTUBEページではコピーメソッドが使用できないようです。

Chromeコンソール画面にて
copy([...document.querySelectorAll("img")].map(e=>e.src).join("\n"));
//copy(Object.keys(document.querySelectorAll("img")).map(key=>document.querySelectorAll("img")[key].src).join("\n"));

ページを自動スクロールします。主に無限スクロールなページなどで活用しています。

※ページの終端になった場合、イベント処理を止める処理が必要になります。

Chromeコンソール画面にて
window.scroll({
    top: window.innerHeight * window.innerHeight,
    behavior: "smooth"
});

window.addEventListener('scroll', function () {
    this.setTimeout(function () {
        window.scroll({
            top: window.innerHeight * window.innerHeight,
            behavior: "smooth"
        })
    }, 5000);
});

Chromeの検証画面Consoleにて下記のコード入力すると文字とか何かダイレクトに変更できます。

document.designMode = 'on';
3
3
2

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
3
3