Modify Desidime Buttons

Change href to data-href and set target to _blank for specified buttons on desidime.com

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.

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

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         Modify Desidime Buttons
// @namespace    http://tampermonkey.net/
// @version      2.0
// @license MIT
// @description  Change href to data-href and set target to _blank for specified buttons on desidime.com
// @author       Dev Goyal
// @match        https://www.desidime.com/*
// @grant        none
// ==/UserScript==



function fixDesiDimeLinks() {
        // Select all buttons with the specified class
    const buttons = document.querySelectorAll('.btn-lgetdeal.home-page-get-deal.gtm-getdeal-home');

    // Iterate over each button and modify the attributes
    buttons.forEach(button => {
        const dataHref = button.getAttribute('data-href');
        if (dataHref) {
            button.setAttribute('href', dataHref);
            button.setAttribute('target', '_blank');
            button.removeAttribute('data-href');
            button.removeAttribute('data-href-alt');

        }
    });
}



// Function to handle DOM changes
function handleDOMChanges(mutationsList) {
    for (const mutation of mutationsList) {
        if (mutation.type === 'attributes' && mutation.attributeName === 'href') {
            // Handle attribute changes (e.g., href attribute)
            fixDesiDimeLinks();
        } else if (mutation.type === 'childList') {
            // Handle changes in the DOM structure (e.g., added nodes)
            fixDesiDimeLinks();
        }
    }
}

// Wrap the MutationObserver setup inside a DOMContentLoaded event listener
document.addEventListener('DOMContentLoaded', () => {
    // Use MutationObserver to detect changes in the document
    const observer = new MutationObserver(handleDOMChanges);

    // Observe changes in the body and its subtree
    observer.observe(document.body, { attributes: true, childList: true, subtree: true });

    // Call fixDesiDimeLinks once when the DOM is ready
    fixDesiDimeLinks();
});