Last active
July 3, 2025 08:43
-
-
Save mariusbolik/fac42cb2d136deab50976ef79b0f8014 to your computer and use it in GitHub Desktop.
Rumpf x mySF (TamperMonkey)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name mySF (Rumpf) | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Injects MyShoeFitter script into websites | |
// @author You | |
// @match https://*/* | |
// @match http://*/* | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== | |
(function () { | |
"use strict"; | |
// Function to load external script | |
function loadScript(src, callback) { | |
const script = document.createElement("script"); | |
script.src = src; | |
script.type = "text/javascript"; | |
script.onload = function () { | |
console.log("MyShoeFitter script loaded successfully"); | |
if (callback) callback(); | |
}; | |
script.onerror = function () { | |
console.error("Failed to load MyShoeFitter script"); | |
}; | |
document.head.appendChild(script); | |
} | |
// Function to initialize MyShoeFitter | |
function initializeMyShoeFitter() { | |
// Wait a bit to ensure the script is fully loaded | |
setTimeout(() => { | |
if (typeof myshoefitter !== "undefined" && myshoefitter.init) { | |
const isMobile = window.innerWidth <= 800; | |
const referenceBtn = isMobile | |
? ".btn-fibbl.mobile" | |
: ".btn-fibbl.js-hide-on-mobile"; | |
const isEng = document | |
.querySelector("html") | |
.getAttribute("lang") | |
.includes("en"); | |
myshoefitter.init({ | |
shopSystem: "shopware", | |
enabledProductNames: ["1567", "1533", "1534", "CH791"], | |
button: { | |
text: isEng ? "Find your size" : "Größe herausfinden", | |
logo: false, | |
attachTo: referenceBtn, | |
position: "after", | |
styles: { | |
position: "absolute", | |
fontSize: "11px", | |
color: "#B20019", | |
border: "1px solid", | |
borderRadius: 0, | |
fontWeight: isMobile ? "unset" : 500, | |
padding: "7px 24px", | |
display: "flex", | |
alignItems: "center", | |
gap: "8px", | |
zIndex: 1, | |
transition: "ease-in-out 0.2s", | |
width: "fit-content", | |
left: isMobile ? "16px" : "280px", | |
top: isMobile ? "unset" : "36px", | |
bottom: isMobile ? "54px" : "unset", | |
}, | |
}, | |
}); | |
console.log("MyShoeFitter initialized successfully"); | |
} else { | |
console.error("MyShoeFitter object not found"); | |
} | |
}, 100); | |
} | |
// Wait for DOM to be ready | |
function domReady(fn) { | |
if ( | |
document.readyState === "complete" || | |
document.readyState === "interactive" | |
) { | |
setTimeout(fn, 1); | |
} else { | |
document.addEventListener("DOMContentLoaded", fn); | |
} | |
} | |
// Execute when DOM is ready | |
domReady(function () { | |
// Load the MyShoeFitter script | |
loadScript( | |
"https://js.myshoefitter.com/v1/script.js", | |
initializeMyShoeFitter | |
); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment