Last active
November 21, 2023 19:05
-
-
Save kemalersin/ca49805b8e8c555e5d3ff96f1ee75df8 to your computer and use it in GitHub Desktop.
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 Steam USD/TL Çeviricisi | |
// @namespace http://tampermonkey.net/ | |
// @author Kemal Ersin YILMAZ | |
// @icon http://store.steampowered.com/favicon.ico | |
// @match http://store.steampowered.com/* | |
// @match https://store.steampowered.com/* | |
// @run-at document-body | |
// @grant GM.xmlHttpRequest | |
// ==/UserScript== | |
/* jshint -W097 */ | |
(async function() { | |
'use strict'; | |
var request = await GM.xmlHttpRequest({ | |
url: 'https://api.genelpara.com/embed/doviz.json' | |
}); | |
if (!request.response) { | |
return; | |
} | |
var json = JSON.parse(request.response); | |
if (!json.USD) { | |
return; | |
} | |
var usdRate = json.USD.satis; | |
var regex = /\$([0-9,]+\.\d{2})\s*(USD)?/; | |
var elements = document.querySelectorAll('.discount_final_price, .game_purchase_price, .game_area_dlc_price, .your_price div'); | |
if (!elements.length) { | |
return; | |
} | |
elements.forEach(function(element) { | |
var match = element.textContent.match(regex); | |
if (match) { | |
var usdPrice = parseFloat(match[1]); | |
var multipliedPrice = usdPrice * usdRate; | |
var formattedMultipliedPrice = multipliedPrice.toLocaleString('tr-TR', { | |
style: 'currency', | |
currency: 'TRY' | |
}); | |
element.textContent += ` (${formattedMultipliedPrice})`; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment