Last active
November 17, 2021 12:42
-
-
Save iwconfig/da9d124977802230732cac0679a3ecfa to your computer and use it in GitHub Desktop.
Detta userscript ändrar lagerstatusen på biltemas produktsidor från "(1+)" till "4 st". En jävla skillnad jöh! Biltema visar endast grovt rundade lagersiffror som (1+), (5+), (25+) osv. Det är inte så att den exakta kvantiteten inte finns tillgängligt för användaren, de visar den inte bara. KOM Å KÖP!!!!!!
This file contains 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 för helvete biltema ge mig exakt lagerstatus | |
// @namespace https://github.com/iwconfig | |
// @version 0.3 | |
// @description 1337 st på lagret istället för (13+) | |
// @author iwconfig | |
// @updateURL https://gist.github.com/iwconfig/da9d124977802230732cac0679a3ecfa/raw/vafan-biltema-exakt-lagerstatus.user.js | |
// @match https://www.biltema.se/* | |
// @icon https://www.google.com/s2/favicons?domain=biltema.se | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const obs = new MutationObserver(muts => { | |
for (let mut of muts) { | |
let el = mut.target.querySelector('.product__section__details .listitem__storestatus--local span') | |
if (!el) continue | |
obs.disconnect() | |
const { articleData, store } = window; | |
const articleId = articleData.split(',')[0]; | |
const state = store.getState(); | |
const stockInfo = state.product.stockInfo.filter(o=>o.articleId==articleId)[0]; | |
el.innerHTML = el.innerHTML.replace(/\(\d+\+\)/, `${stockInfo.quantity} st`); | |
break | |
} | |
}); | |
obs.observe(document, {childList: true, subtree: true}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment