// ==UserScript==
// @name Auto-Expand All "Show More" buttons + Others (QoL)
// @version 3.4
// @description Brave: Auto-expands a lot of the buttons for easier browsing more information the merrier.
// @author Misspent & OpenAI
// @namespace https://chatbot.theb.ai
// @match https://search.brave.com/search?q=*
// @icon https://i.imgur.com/HBBSMUb.png
// @license MIT
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
// Configuration for auto-click functions
const config = [
{ name: 'ShowMoreSidebar', selector: ".fdb.infobox .footer > .btn--text.btn--sm.btn", interval: 800 },
{ name: 'SpellCorrectAnswer', selector: '#info-banners #altered-query a.desktop-default-semibold[href*="&spellcheck=0&source=alteredQuery"]', interval: 0 },
{ name: 'ShowMoreDefinition', selector: "#definition .button", interval: 0 },
{ name: 'MoreAboutSidebar', selector: '.infobox-factsheet-show-more', interval: 300, condition: el => el.textContent.trim().startsWith('More about') },
{ name: 'ShowMoreSidebar2', selector: 'aside .action-wrapper button[rel="noopener"] span', interval: 200, condition: el => el.textContent === 'Show more' },
{ name: 'MoreAboutSidebar3', selector: '#attr-show-more button', interval: 300, condition: el => el.textContent.trim().startsWith('More about') },
{ name: 'ShowMoreSummarizer', selector: '#summarizer button[rel="noreferrer noopener"]', interval: 600 },
{ name: 'MoreNewAIContainer', selector: '#llm-container .visible .content-wrapper-footer-button button.type--footer-prominent', interval: 500 },
{ name: 'MoreNewAIResultsContainer', selector: '#llm-show-more-button', interval: 700 },
{ name: 'MoreNewAIResultsURLContainer', selector: '#chatllm-context button.context-other-results-card', interval: 900 },
{ name: 'MoreNewAILinkCards', selector: '#llm-container #chatllm-context button.more-card', interval: 600 },
{ name: 'MoreNewAILinkButtonCards', selector: '#llm-snippet .context-results button.context-other-results-card', interval: 1000 },
{ name: 'RedditDiscussionContainer', selector: '#discussions .action-container button:first-child span', interval: 0, condition: el => el.textContent === 'Show more' },
{ name: 'ShowMoreDiscussions', selector: '#discussions .button.size--tiny.type--outlined.type span', interval: 0, condition: el => el.textContent === 'Show more' }
];
// Function to perform auto-click based on configuration
function autoClick({selector, condition}) {
const elements = document.querySelectorAll(selector);
if (elements.length > 0) {
const elementToClick = elements[0];
if (!condition || condition(elementToClick)) {
elementToClick.click();
}
}
}
// Initial run and set intervals for all configured functions
config.forEach(({selector, condition, interval}) => {
autoClick({selector, condition});
if (interval > 0) {
setInterval(() => autoClick({selector, condition}), interval);
} else {
// Use MutationObserver for elements with an interval of 0
const observer = new MutationObserver(() => autoClick({selector, condition}));
observer.observe(document.body, { childList: true, subtree: true });
}
});
})();
/* OLD:
(function() {
'use strict';
// Auto-Click "Show More" on sidebar
function clickShowMoreSidebar() {
document.querySelectorAll(".fdb.infobox .footer > .btn--text.btn--sm.btn").forEach(function(item) {
item.click();
});
}
// Auto-Click Correct auto correct suggestion
function clickSpellCorrectAnswer() {
document.querySelectorAll('#info-banners #altered-query a.desktop-default-semibold[href*="&spellcheck=0&source=alteredQuery"]').forEach(function(item) {
item.click();
});
}
// Auto-Click "Show More" on definition snippet
function clickShowMoreDefinition() {
document.querySelectorAll("#definition .button.svelte-9gmgko").forEach(function(item) {
item.click();
});
}
// Auto-Click "More about {subject}" on sidebar | 1st
function clickMoreAboutSidebar() {
const elements = document.querySelectorAll('.infobox-factsheet-show-more');
if (elements.length > 0) {
const buttonText = elements[0].textContent.trim();
if (buttonText.startsWith('More about')) {
elements[0].click();
}
}
}
// Auto-Click "Show more" on sidebar | 2nd
function clickShowMoreSidebar2() {
const buttons = document.querySelectorAll('aside .action-wrapper button[rel="noopener"]');
buttons.forEach(button => {
const span = button.querySelector('span');
if (span && span.textContent === 'Show more') {
button.click();
}
});
}
// Auto-Click "More about {subject}" on sidebar | 3rd
function clickMoreAboutSidebar3() {
const elements = document.querySelectorAll('#attr-show-more button');
if (elements.length > 0) {
const buttonText = elements[0].textContent.trim();
if (buttonText.startsWith('More about')) {
elements[0].click();
}
}
}
// Auto-Click "Show more" for Summarizer
function clickShowMoreSummarizer() {
var elements = document.querySelectorAll('#summarizer button[rel="noreferrer noopener"]');
if (elements.length > 0) {
elements[0].click();
}
}
// Auto-Click "More" for New AI
function clickMoreNewAIContainer() {
var elements = document.querySelectorAll('#llm-container .visible .content-wrapper-footer-button button.type--footer-prominent');
if (elements.length > 0) {
elements[0].click();
}
}
// Auto-Click "More" for New AI in main results
function clickMoreNewAIResultsContainer() {
var elements = document.querySelectorAll('#llm-show-more-button');
if (elements.length > 0) {
elements[0].click();
}
}
// Auto-Click "More" for New AI in main results
function clickMoreNewAIResultsURLContainer() {
var elements = document.querySelectorAll('#chatllm-context button.context-other-results-card');
if (elements.length > 0) {
elements[0].click();
}
}
// Auto-Click "More" for more cards in new snippet
function clickMoreNewAILinkCards() {
var elements = document.querySelectorAll('#llm-container #chatllm-context button.more-card');
if (elements.length > 0) {
elements[0].click();
}
}
// Auto-Click "+ More" for more website link buttons in new main result snippet (below Follow up section)
function clickMoreNewAILinkButtonCards() {
var elements = document.querySelectorAll('#llm-snippet .context-results button.context-other-results-card');
if (elements.length > 0) {
elements[0].click();
}
}
// Auto-Click Reddit Discussion show more
function clickRedditDiscussionContainer() {
const buttons = document.querySelectorAll('#discussions .action-container button:first-child');
buttons.forEach(button => {
const span = button.querySelector('span');
if (span && span.textContent === 'Show more') {
button.click();
}
});
}
// Auto-Click "Show More" for Discussions box
function clickShowMoreDiscussions() {
const buttons = document.querySelectorAll('#discussions .button.svelte-9gmgko.size--tiny.type--outlined.type');
buttons.forEach(button => {
const span = button.querySelector('span');
if (span && span.textContent === 'Show more') {
button.click();
}
});
}
// Run all the functions initially
clickShowMoreSidebar();
clickSpellCorrectAnswer();
clickShowMoreDefinition();
clickMoreAboutSidebar();
clickShowMoreSidebar2();
clickMoreAboutSidebar3();
clickShowMoreSummarizer();
clickShowMoreDiscussions();
clickMoreNewAIContainer();
clickMoreNewAILinkCards();
clickMoreNewAIResultsContainer();
clickRedditDiscussionContainer();
clickMoreNewAIResultsURLContainer();
clickMoreNewAILinkButtonCards();
// Add intervals to continuously check for certain buttons | You can adjust the interval time (in milliseconds) as needed
setInterval(clickMoreAboutSidebar, 800);
setInterval(clickSpellCorrectAnswer, 1800);
setInterval(clickShowMoreSidebar2, 200);
setInterval(clickMoreAboutSidebar3, 300);
setInterval(clickShowMoreSummarizer, 400);
setInterval(clickMoreNewAIContainer, 500);
setInterval(clickMoreNewAILinkCards, 600);
setInterval(clickMoreNewAIResultsContainer, 700);
setInterval(clickRedditDiscussionContainer, 0);
setInterval(clickMoreNewAIResultsURLContainer, 900);
setInterval(clickMoreNewAILinkButtonCards, 1000);
const intervalId = setInterval(clickShowMoreDiscussions, 0);
})();
*/