quora-only-answers

Changes the filter drop-down in Quora questions from "All related (n)" to "Answers (n)", avoiding the annoying "related" questions/answers.

Stan na 10-12-2022. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        quora-only-answers
// @namespace   chester.me
// @match       https://www.quora.com/*
// @grant       none
// @version     1.0
// @author      @chesterbr
// @supportURL  https://github.com/chesterbr/quora-only-answers/issues
// @license     MIT
// @description Changes the filter drop-down in Quora questions from "All related (n)" to "Answers (n)", avoiding the annoying "related" questions/answers.
// @noframes
// ==/UserScript==
function clickDropdown() {
    var dropdownCandidates = Array.from(document.querySelectorAll("button"));
    for (var _i = 0, dropdownCandidates_1 = dropdownCandidates; _i < dropdownCandidates_1.length; _i++) {
        var dropdown = dropdownCandidates_1[_i];
        if (dropdown.innerText.startsWith("All related")) {
            dropdown.click();
            return true;
        }
    }
    return false;
}
function clickAnswers() {
    if (!attemptToClickAnswers()) {
        window.setTimeout(clickAnswers, 100);
    }
}
var MAX_ATTEMPTS = 50;
var attemptCount = 0;
function attemptToClickAnswers() {
    var menuItems = Array.from(document.querySelectorAll("div"));
    for (var _i = 0, menuItems_1 = menuItems; _i < menuItems_1.length; _i++) {
        var menuItem = menuItems_1[_i];
        if (menuItem.innerText.startsWith("Answers (")) {
            window.setTimeout(function () {
                menuItem.click();
            }, 100);
            return true;
        }
    }
    // Menu item did not render yet; keep trying until we reach the limit
    attemptCount++;
    return attemptCount > MAX_ATTEMPTS;
}
/////// Main entry point
if (clickDropdown()) {
    clickAnswers();
}