Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
srcemre committed Nov 24, 2023
0 parents commit 5c0ea35
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
![](assets/logo.png)

# Steam Türk Lirasına Çevirme

Steam Turkey Store now uses Dollars instead of Turkish Lira due to our fascinating economy. This plugin has been created by using the [Exchange Rate API](https://www.exchangerate-api.com), which calculates the prices according to the current exchange rate and shows them in Turkish lira instead of dollars.

Chrome Web Store: [Steam Türk Lirasına Çevirme](https://chromewebstore.google.com/detail/steam-t%C3%BCrk-liras%C4%B1na-%C3%A7evir/amjkkjgaoobiepemkmiefmmbdeeindoj),

[![](assets/store.png)](https://chromewebstore.google.com/detail/steam-t%C3%BCrk-liras%C4%B1na-%C3%A7evir/amjkkjgaoobiepemkmiefmmbdeeindoj)


---
**Bug reports, feature requests and pull requests are always welcome**
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name":"Steam Türk Lirasına Çevirme",
"description" : "Steam Mağaza oyun fiyatlarını güncel dolar kuruna göre TL olarak görüntülemesini sağlar.",
"version":"1.0.1",
"manifest_version":3,
"icons": {
"16": "/icons/icon16.png",
"32": "/icons/icon32.png",
"48": "/icons/icon48.png",
"128": "/icons/icon128.png"
},
"content_scripts": [
{
"matches": ["https://store.steampowered.com/*"],
"js": ["scripts/content-scripts.js"]
}
],
"action":{
"default_popup":"options/popup.html",
"default_icon": {
"16": "/icons/icon16.png",
"32": "/icons/icon32.png",
"48": "/icons/icon48.png",
"128": "/icons/icon128.png"
}
}
}
17 changes: 17 additions & 0 deletions options/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="popup_css_compiled.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<img id="logo" src="../icons/icon128.png" alt="Extension Logo">
<div id="text-and-button">
<h3>Steam Türk Lirasına Çevirme</h3>
<p>Bug reports, feature requests and pull requests are always welcome.</p>
<a id="github-button" href="https://github.com/srcemre/steamTurkishLiraExtensions" target="_blank"><i class="fa fa-github"></i></i> Visit GitHub Repository</a>
</div>
</body>
</html>
Empty file added options/popup.js
Empty file.
34 changes: 34 additions & 0 deletions options/popup_css_compiled.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
body {
font-family: 'Arial', sans-serif;
background: rgb(135,35,65);
background: linear-gradient(4deg, rgba(135,35,65,1) 0%, rgba(34,9,44,1) 50%);
color: #fd5b43;
margin: 0;
padding: 8px;
width: 380px;
display: flex;
align-items: center; /* Align items vertically in the center */
}

#logo {
width: 128px;
height: 128px;
margin-right: 16px;
}

#text-and-button {
display: flex;
flex-direction: column;
align-items: flex-start; /* Align items to the start (left) */
}

#github-button {
background-color: #333;
color: #fff;
padding: 5px;
border: none;
cursor: pointer;
text-decoration: none;
border-radius: 5px;
}

73 changes: 73 additions & 0 deletions scripts/content-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
let extensionExecuted = false;

async function replaceDiscountPrices() {

if (extensionExecuted) {
return;
}

// Sayfadaki çevrilmesini istediğin kısımların <div> elementlerini seç
const discountOriginalPrice = document.querySelectorAll('.discount_original_price');
const discountElements = document.querySelectorAll('.discount_final_price');
const gameAreaDlcPrice = document.querySelectorAll('.game_area_dlc_price');
const price = document.querySelectorAll('.price');

const exchangeRate = await getExchangeRate();

discountElements.forEach((element) => {
element.textContent = changeText(element.textContent, exchangeRate)
});
discountOriginalPrice.forEach((element) => {
element.textContent = changeText(element.textContent, exchangeRate)
});
price.forEach((element) => {
element.textContent = changeText(element.textContent, exchangeRate)
});
gameAreaDlcPrice.forEach((element) => {

if (element.querySelectorAll('.discount_prices').length==0)
return;

element.textContent = changeText(element.textContent, exchangeRate);

});

extensionExecuted = true;
}

function changeText( originalContent, exchangeRate) {
const matches = originalContent.match(/(\D+)([\d.]+)/);
if (matches && matches.length === 3) {
const currencySymbol = '₺';
const amount = parseFloat(matches[2]);
if (!isNaN(amount)) {
const convertedAmount = (amount * exchangeRate).toFixed(2);
const convertedContent = currencySymbol + ' ' + convertedAmount + ' TL';
return convertedContent;
}
}
return originalContent;
}

async function getExchangeRate() {
const apiKey = '';
try {
const response = await fetch(`https://v6.exchangerate-api.com/v6/${apiKey}/latest/USD`);
if (!response.ok) {
throw new Error('Unable to get exchange rate: ' + response.status);
}

const data = await response.json();
const exchangeRate = data.conversion_rates.TRY;

return exchangeRate;
} catch (error) {
console.error('Unable to get exchange rate:', error.message);
return null;
}
}

replaceDiscountPrices();

var observer = new MutationObserver(replaceDiscountPrices);
observer.observe(document.body, { subtree: false, childList: true });
Empty file added service-worker.js
Empty file.

0 comments on commit 5c0ea35

Please sign in to comment.