goToOnlineshop-Preise.ch

Den Preisverlauf von Artikeln aus dem digitec.ch Shop über die Webseite onlineshop-preise.ch anzeigen.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         goToOnlineshop-Preise.ch
// @namespace    http://c-dev.ch/
// @version      0.3
// @description  Den Preisverlauf von Artikeln aus dem digitec.ch Shop über die Webseite onlineshop-preise.ch anzeigen.
// @author       kaepten neisgei
// @match        https://www.digitec.ch/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    setTimeout(function(){console.log("first time render"); render();}, 500);

    window.setInterval(function(){
        console.log("interval render");
        var exists = document.getElementById("preisverlauf");
        if(exists == null){
            render();
        }
    }, 2000);



    function render() {

        var exists = document.getElementById("preisverlauf");
        if(exists != null){
            return;
        }

        var aTags = document.getElementsByTagName("div");
        var searchText = "Teilen";
        var found;

        for (var i = 0; i < aTags.length; i++) {
            if (aTags[i].textContent == searchText) {
                found = aTags[i];
                break;
            }
        }

        if(found == null) return;
        
        console.log("...do render!...");

        var divAreaE = found.parentNode.parentNode.parentNode;

        var oldUrl = window.location.href;
        var newUrl = 'https://www.onlineshop-preise.ch/'
        newUrl = oldUrl.replace("https:\/\/www\.digitec\.ch\/",newUrl);

        var divP = document.createElement('div');
        divP.id = "preisverlauf";
        divAreaE.appendChild(divP);

        divP.innerHTML = "<button id=\"prBtn\" type=\"button\" style=\"margin-top: 20px; padding: 10px 10px;    position: relative;    display: inline-block;    border: 0px;    font-family: Roboto, Arial, sans-serif;    letter-spacing: normal;    line-height: 1.4;    text-align: center;    cursor: pointer;    vertical-align: middle;    text-decoration: none;    border-radius: var(--dg-spacingHalf);    appearance: none;    transition: padding 100ms ease 0s;    white-space: nowrap;    font-size: 1rem;    background: #FFA500;    color: #000000; width: 100%\"><span>Preisverlauf - onlineshop-preise</span></button>";
        divP.onclick = function() {window.open(newUrl, '_blank');};

        var prBtn = document.getElementById("prBtn");
        prBtn.addEventListener("mouseover", function () {prBtn.style.background = "#B22222"; prBtn.style.color = "#FFFFFF";});
        prBtn.addEventListener("mouseout", function () {prBtn.style.background = "#FFA500"; prBtn.style.color = "#000000";});

        return true;
    }

})();