Greasy Fork is available in English.

Quora Enhancement

Make specific elements less wide on a page, remove Advertisement

// ==UserScript==
// @name         Quora Enhancement
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Make specific elements less wide on a page, remove Advertisement
// @author       aspen138
// @match        *://www.quora.com/*
// @icon        https://qsf.cf2.quoracdn.net/-4-images.favicon-new.ico-26-07ecf7cd341b6919.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to adjust width and position with animation
    function adjustWidthAndPosition() {
        // Find elements by the class name and specific inline style
        const elements = document.querySelectorAll('.q-box[style*="width: 356px;"]');

        // Loop through found elements and adjust width and position with animation
        elements.forEach(function(element) {
            element.style.transition = 'width 0.5s ease-in-out, right 0.5s ease-in-out'; // Animate width and right property
            element.style.width = '156px'; // Adjust width as desired
            element.style.position = 'relative'; // Set position to relative
            element.style.right = '0px'; // Move closer to the right, adjust as needed
        });

        // Find elements by the class name and specific inline style
        const elements1 = document.querySelectorAll('.q-box[id="mainContent"]');

        // Loop through found elements and adjust width and position with animation
        elements1.forEach(function(element) {
            element.style.transition = 'width 0.5s ease-in-out'; // Animate width property
            element.style.width = '956px'; // Adjust width as desired
            element.style.position = 'relative'; // Set position to relative
            // Animation for moving to the right is not necessary here as the original code was commented out
        });

    }

    // Run the adjustment function after the page loads
    window.addEventListener('load', adjustWidthAndPosition);



// ------------ Function to remove the ad ------------
    // Function to remove the ad
    function removeAd() {
        // Using querySelectorAll to find all elements that match the ad's characteristics
        const ads = document.querySelectorAll('.q-box.spacing_log_question_page_ad, #bunwaeabjd');

        ads.forEach(ad => {
            // Removing each ad found
            if (ad) ad.remove();
        });
    }

    // Run the removeAd function on page load
    window.addEventListener('load', removeAd);

    // Optionally, run the removeAd function periodically to catch and remove ads that load asynchronously
    setInterval(removeAd, 3000); // Checks and removes ads every 3 seconds
// ------------ Function to remove the ad ------------

})();