LoginSignup
0
0

More than 3 years have passed since last update.

Qiita記事のコメント欄を内容直下に移動するユーザースクリプト

Posted at

コメント欄を記事内容直下に移動し、スクロールの手間を減らします。
greasemonkeytampermonkey でご利用ください。

ページ読み込み直後に一瞬カクつくのは仕様です。(ある程度スクロールしないとコメントが表示されないため、最下部までスクロールさせて戻しています)

コメントの確認を目的としていたので、移動後のコメント入力欄が問題なく動作するかは未確認です。

// ==UserScript==
// @name         Qiita記事のコメント欄移動
// @version      1.0
// @match        *://qiita.com/*/items/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const scrollX = window.scrollX;
    const scrollY = window.scrollY;
    scrollTo(0, document.getElementsByTagName('body')[0].scrollHeight);
    setTimeout(function() { scrollTo(scrollX, scrollY); }, 50);

    const mo = new MutationObserver(function() {
        const comment = document.getElementById('comments');
        const userInfo = document.getElementsByClassName('ai-Container');
        if (comment && userInfo.length) {
            userInfo[0].parentElement.insertBefore(comment, userInfo[0]);
            mo.disconnect();
        }
    });
    mo.observe(document.getElementsByClassName('p-items')[0], {childList: true, subtree: true});
})();
0
0
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
0