Show Quora upvotes

Shows previously hidden upvotes in a Quora feed

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Show Quora upvotes
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  Shows previously hidden upvotes in a Quora feed
// @author       ncg
// @match        https://www.quora.com/
// @grant        none
// ==/UserScript==

const hiddenElementClass = 'hide_in_feed',
      hiddenElementSelector = `.${hiddenElementClass}`;
const feedSelector = '.paged_list_wrapper';
const upvoteButtonSelector = '.Upvote.Button';

function showUpvotesInAnswer(answerElement) {
    let hiddenElement;

    if (!(hiddenElement = answerElement.querySelector(hiddenElementSelector))) {
        return;
    }

    hiddenElement.classList.remove(hiddenElementClass);
}

const feed = document.querySelector(feedSelector);

const mutationObserver = new MutationObserver(function(mutations) {
    mutations.forEach(mutation => {
        mutation.addedNodes.forEach(element => {
            showUpvotesInAnswer(element);
        });
    });
});

mutationObserver.observe(feed, { childList: true });

// Show upvotes for first answers in feed

for (const upvoteButton of document.querySelectorAll(upvoteButtonSelector)) {
    showUpvotesInAnswer(upvoteButton);
}