cppref-hashtag

Add Python-doc-like links to cppreference

11.06.2021 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         cppref-hashtag
// @namespace    mailto:[email protected]
// @version      0.1.1
// @description  Add Python-doc-like links to cppreference
// @author       QuarticCat
// @match        https://*.cppreference.com/*
// @icon         https://www.google.com/s2/favicons?domain=cppreference.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict'

    // Inject CSS class
    document.getElementsByTagName('head')[0].innerHTML += `
        <style type="text/css">
            a.headerlink {
                color: #0072aa;
                /* font-size: 0.8em; */
                /* padding: 0 4px 0 4px; */
                text-decoration: none;
                visibility: hidden;
            }
        </style>
    `

    for (let headline of document.getElementsByClassName('mw-headline')) {
        // Inject links
        headline.insertAdjacentHTML('afterend', `
            <a class="headerlink" href="#${headline.id}" title="Permalink to this headline">¶</a>
        `)

        // Add hover events
        const parent = headline.parentNode
        const link = headline.nextElementSibling
        parent.addEventListener('mouseenter', () => {
            link.style.visibility = 'visible'
        })
        parent.addEventListener('mouseleave', () => {
            link.style.visibility = 'hidden'
        })
    }
})();