Skip to content

Instantly share code, notes, and snippets.

@Far-Se
Created February 3, 2022 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Far-Se/25dbbb77b34096178f5d3881b0a7ed6a to your computer and use it in GitHub Desktop.
Save Far-Se/25dbbb77b34096178f5d3881b0a7ed6a to your computer and use it in GitHub Desktop.
Pricy Info under images
// ==UserScript==
// @name PricyGraph
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.emag.ro/*
// @icon https://icons.duckduckgo.com/ip2/emag.ro.ico
// @grant GM_xmlhttpRequest
// ==/UserScript==
setInterval(()=>{
if(!document.querySelector('.has-subtitle-info'))return;
if(document.getElementById('pricyGraph'))return;
const link = encodeURIComponent(location.href);
const title = encodeURIComponent(document.title);
const pricyLink = `https://www.pricy.ro/extension/getpricehistoryinpopup/93?currency=RON&url=${link}&title=${title}`;
document.querySelector('.product-gallery-wrapper.product-gallery-www').insertAdjacentHTML('afterend','<div id="pricyGraph"></div>');
document.querySelector('#pricyGraph').insertAdjacentHTML('beforeend',`<iframe src="https://www.pricy.ro/extensionhtml?url=${link}&title=${title}&v=4.5.1-Chrome" frameborder="0" width="1000" height="300" style="width:100vw !important"></iframe>`);
1 || GM_xmlhttpRequest({
method: "GET",
url: pricyLink,
onload: function(response) {
const data = JSON.parse(response.responseText);
const prices = data.PriceHistory;
const priceHistory = prices.map(e=>e.Price).join(',');
const dateHistory = prices.map(e=> new Date(e.Timestamp).toISOString().slice(5,10)).join(',');
console.log(dateHistory);
const link = `https://quickchart.io/chart/render/zm-24b6b169-7212-4886-9619-2ce8aa74dcf2?data1=${priceHistory}&labels=${dateHistory}`
console.log(link);
document.querySelector('#pricyGraph').insertAdjacentHTML('beforeend',`<iframe src="${link}" frameborder="0" width="1000" height="300" style="width:100vw !important"></iframe>`);
}
});
},100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment