Geeksforgeeks browse improve all in one

Geeksforgeeks browse improve ultra

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Geeksforgeeks browse improve all in one
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Geeksforgeeks browse improve ultra
// @author       fvydjt
// @match        https://www.geeksforgeeks.org/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=geeksforgeeks.org
// @grant        GM_addStyle
// ==/UserScript==

let content = document.querySelector('.leftBar');
let sidebar = document.querySelector('.sidebar_wrapper');
sidebar.style.cssText = 'display:auto';
let btn;

let toggle = () => {
    let mark = document.querySelector('#btn');
    if (mark.innerText == '<') {
        sidebar.style.cssText = 'display:none';
        content.setAttribute('style', 'min-width: calc(100%) !important;');
        mark.innerText = '>';
        btn.style.left = '0px';
    } else if (mark.innerText == '>') {
        sidebar.style.cssText = 'display:auto';
        content.setAttribute('style', 'min-width: calc(80%) !important;');
        mark.innerText = '<';
        btn.style.left = '238px';
    }
};

(function () {
    'use strict';
    let cancelSticky = `
        .make_sticky {
            position: initial !important;
        }
    `;
    let sidebarChangeStyle = `
        .sidebar_wrapper {
            border:solid;
            border-color:white black white white;
        }
    `;
    // unfold the list
    let sidebarChangeHeight = `
        .sideBar {
            height:100% !important;
        }
    `;
    let cancelHeaderSticky = `
        .header-main__slider {
            position:initial !important;
        }
    `;
    GM_addStyle(cancelSticky);
    GM_addStyle(sidebarChangeStyle);
    GM_addStyle(sidebarChangeHeight);
    GM_addStyle(cancelHeaderSticky);

    // init text area width
    content.setAttribute('style', 'min-width: calc(80%) !important;');

    // remove ads in article
    let ads = document.querySelectorAll('.inArticleAds');
    for (let i = 0; i < ads.length; i++) {
        ads.outerHTML = '';
    }

    // create button for menu control
    let body = document.querySelector('body');
    btn = document.createElement('div');
    btn.setAttribute('id', 'btn');
    btn.style.cssText = 'position: fixed;z-index: 1;left: 238px;top: 300px;width: 20px;height: 30px;background: #308d46;font-size: 18px;border-radius: 0% 100% 100% 0%;padding-left: 2px;padding-top: 4px;font-weight: bold;color: #cddc39;user-select:none;';
    // btn.setAttribute('style', 'position: fixed;z-index: 1;left: 238px;top: 300px;width: 20px;height: 30px;background: #308d46;font-size: 18px;border-radius: 0% 100% 100% 0%;padding-left: 2px;padding-top: 4px;font-weight: bold;color: #cddc39;user-select:none;');
    let text_in = document.createTextNode('<');
    btn.appendChild(text_in);
    body.appendChild(btn);

    btn.addEventListener('click', toggle);

    // right bar remove
    document.getElementById('.rightBar').style.display = "none";

    // Stop GeeksForGeeks from opening its stupid login modal
    // author: https://github.com/khang06
    localStorage.setItem("gfgViewCount", 0);
    localStorage.setItem("guestPageCount", 0);

})();