Hazır kriptoda hareketlilik başladı, kendime 3 tane eklenti yazdım arkadaşlar. sizlerle de paylaşayım. kullanmak isteyen dilediği gibi kullanabilir. üç eklenti de 1saniye aralıklı yenileniyor.
Ekran görüntüsü bendekinin böyle. Soldaki koinin fiyatı, ortadaki kar/zarar durumu, sağdaki kasa durumu. hepsi dolar bazlı gösterim. alan dar olduğundan olabildiğince sığdırmaya çalıştım o yüzden kur vs yazamadım.
Chrome eklenti hazırlama ve yüklemeyi bilen arkadaşlar direkt ekler. Bilmeyen arkadaşlar da biraz araştırırsa bulabilir nasıl yapacaklarını.
İlk kod: Koin fiyatının anlık takibi için background.js const API_URL = "https://api.binance.com/api/v3/ticker/price?symbol=SUIUSDT";
async function updatePrice() {
try {
const response = await fetch(API_URL);
const data = await response.json();
const price = parseFloat(data.price);
chrome.action.setBadgeText({ text: price.toFixed(3) });
chrome.action.setBadgeBackgroundColor({ color: "#4CAF50" });
console.log("Fiyat güncellendi: $" + price.toFixed(3));
} catch (error) {
console.error("Fiyat alınamadı:", error);
chrome.action.setBadgeText({ text: "ERR" });
chrome.action.setBadgeBackgroundColor({ color: "#FF0000" });
}
}
updatePrice();
setInterval(updatePrice, 1000);manifest.json {
"manifest_version": 3,
"name": "SUI Fiyat Takipçisi",
"version": "1.0",
"description": "SUI koinin fiyatını araç çubuğunda gösterir.",
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"action": {
"default_title": "SUI/USDT"
},
"background": {
"service_worker": "background.js"
},
"permissions": ["alarms"]
}İkinci kod: Kar/zarar durumunu göstermesi için background.js const API_URL = "https://api.binance.com/api/v3/ticker/price?symbol=SUIUSDT";
const ENTRY_PRICE = 3.7325; // Başlangıç fiyatını ($)
const POSITION_SIZE = 1613.4472; // İşlem büyüklüğü ($)
const LEVERAGE = 3; // Kaldıraç
function formatNumber(value) {
if (value >= 1_000_000) {
return (value / 1_000_000).toFixed(0) + "M";
} else if (value >= 1_000) {
return (value / 1_000).toFixed(0) + "K";
} else {
return value.toFixed(0);
}
}
async function updatePosition() {
try {
const response = await fetch(API_URL);
const data = await response.json();
const currentPrice = parseFloat(data.price);
console.log("Anlık Fiyat: $" + currentPrice);
const positionValue = POSITION_SIZE * LEVERAGE * (currentPrice / ENTRY_PRICE);
const profitLoss = positionValue - (POSITION_SIZE * LEVERAGE);
const profitLossText = formatNumber(profitLoss);
chrome.action.setBadgeText({ text: profitLossText });
chrome.action.setBadgeBackgroundColor({
color: profitLoss >= 0 ? "#4CAF50" : "#FF0000",
});
console.log(
`Güncelleme: Pozisyon Değeri: $${formatNumber(positionValue)}, Kar/Zarar: $${profitLossText}`
);
} catch (error) {
console.error("Fiyat alınamadı:", error);
chrome.action.setBadgeText({ text: "ERR" });
chrome.action.setBadgeBackgroundColor({ color: "#FF0000" });
}
}
updatePosition();
setInterval(updatePosition, 1000);manifest.json {
"manifest_version": 3,
"name": "SUI Long Position Tracker",
"version": "1.0",
"description": "SUI fiyatına göre 3x kaldıraçlı long pozisyonun kar/zarar durumunu gösterir.",
"permissions": ["activeTab"],
"background": {
"service_worker": "background.js"
},
"action": {
"default_title": "SUI Long Position Tracker",
"default_icon": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
}
}
}Üçüncü kod: Toplam kasanın durumu için (işlemde olan ve kenarda bekleyen tutarın toplamının anlık değişimi) background.js const API_URL = "https://api.binance.com/api/v3/ticker/price?symbol=SUIUSDT";
const ENTRY_PRICE = 3.7325; // Başlangıç fiyatı ($)
const POSITION_SIZE = 1613.4472; // İşlem büyüklüğü ($)
const LEVERAGE = 3; // Kaldıraç
const PENDING_BALANCE = 1265.63761771; // Kenarda bekleyen para ($)
function formatNumber(value) {
if (value >= 1_000_000) {
return (value / 1_000_000).toFixed(2) + "M";
} else if (value >= 1_000) {
return (value / 1_000).toFixed(2) + "K";
} else {
return Math.round(value);
}
}
async function updateBalance() {
try {
const response = await fetch(API_URL);
const data = await response.json();
const currentPrice = parseFloat(data.price);
console.log("Anlık Fiyat: $" + currentPrice);
const positionValue = POSITION_SIZE * LEVERAGE * (currentPrice / ENTRY_PRICE);
const profitLoss = positionValue - (POSITION_SIZE * LEVERAGE);
const totalBalance = PENDING_BALANCE + profitLoss + POSITION_SIZE;
const totalBalanceText = formatNumber(totalBalance);
chrome.action.setBadgeText({ text: totalBalanceText });
chrome.action.setBadgeBackgroundColor({
color: totalBalance >= 0 ? "#4CAF50" : "#FF0000",
});
console.log(
`Toplam Kasa Durumu: $${totalBalanceText}, Kar/Zarar: $${formatNumber(profitLoss)}`
);
} catch (error) {
console.error("Fiyat alınamadı:", error);
chrome.action.setBadgeText({ text: "ERR" });
chrome.action.setBadgeBackgroundColor({ color: "#FF0000" });
}
}
updateBalance();
setInterval(updateBalance, 1000);manifest.json {
"manifest_version": 3,
"name": "Toplam Kasa Durumu",
"version": "1.0",
"description": "SUI koininin anlık fiyatı ve işlem durumu ile toplam kasanızı görüntüler.",
"permissions": ["activeTab"],
"background": {
"service_worker": "background.js"
},
"action": {
"default_title": "Kasa Takibi",
"default_icon": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
}
}
}