Cài đặt extension Tampermonkey trong Edge (mở đúng tab FireAnt - Biểu đồ dạng TAB)
Đây là phiên bản Tampermonkey MVP (chạy thử nghiệm đầu tiên) để:
✅ Nút⚙️bên cạnh mã cổ phiếu để nhập giá vốn (có thể nhập giá Close cây tạo đáy VNI)
✅ Lưu vào LocalStorage
✅ Hiển thị Giá vốn + % lời/lỗ ngay dưới giá hiện tại
✅ Tự cập nhật mỗi 2 giây
Cài script mới trong Tampermonkey và dán toàn bộ:
// ==UserScript==
// @name FireAnt Portfolio Overlay
// @namespace https://fireant.vn/
// @version 1.0
// @description Thêm giá vốn và % lời lỗ vào FireAnt Watchlist
// @author TSM
// @match https://fireant.vn/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
const STORAGE_KEY = 'fireant_costs';
function loadCosts() {
try {
return JSON.parse(localStorage.getItem(STORAGE_KEY)) || {};
} catch (e) {
return {};
}
}
function saveCosts(data) {
localStorage.setItem(
STORAGE_KEY,
JSON.stringify(data)
);
}
function getCost(symbol) {
const data = loadCosts();
return data[symbol];
}
function setCost(symbol, cost) {
const data = loadCosts();
data[symbol] = parseFloat(cost);
saveCosts(data);
}
function getRows() {
return document.querySelectorAll(
'.list-row'
);
}
function processRow(row) {
const link = row.querySelector(
'a[href*="/charts/content/symbols/"]'
);
if (!link) return;
const symbol =
link.textContent.trim();
// ==========================
// Nút chỉnh giá vốn
// ==========================
let editBtn =
row.querySelector('.tm-edit-cost');
if (!editBtn) {
editBtn =
document.createElement('span');
editBtn.className =
'tm-edit-cost';
editBtn.textContent = '⚙️';
editBtn.style.cursor = 'pointer';
editBtn.style.marginLeft = '6px';
editBtn.style.fontSize = '12px';
editBtn.addEventListener(
'click',
function (e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
const value =
prompt(
`Nhập giá vốn ${symbol}`,
getCost(symbol) || ''
);
if (
value === null ||
value === ''
) return;
setCost(
symbol,
value
);
updateAll();
},
true
);
link.insertAdjacentElement('afterend',editBtn);
}
// ==========================
// Giá hiện tại
// ==========================
const priceNode =
row.querySelector(
'.sc-fHheEh span'
);
if (!priceNode) return;
const currentPrice =
parseFloat(
priceNode.innerText
.replace(',', '')
);
if (isNaN(currentPrice))
return;
const cost =
getCost(symbol);
let info =
row.querySelector('.tm-profit-box');
if (!info) {
info = document.createElement('div');
info.className = 'tm-profit-box';
info.style.gap = '6px';
info.style.marginLeft = '6px';
info.style.fontSize = '9px';
const priceContainer = priceNode.parentElement;
priceContainer.appendChild(info);
}
// ==========================
// Chưa nhập giá vốn
// ==========================
if (
cost === undefined || cost === null
) {
info.innerHTML = '';
return;
}
// ==========================
// Tính lời lỗ
// ==========================
const pl =
(
(
currentPrice - cost
)
/ cost
* 100
).toFixed(2);
const color =
pl >= 0
? '#00aa00'
: '#ff3333';
info.innerHTML = `
<span style="
color:#888;
white-space:nowrap;
font-weight:600;
">
💰 ${cost}
</span>
<span style="
color:${color};
font-weight:700;
white-space:nowrap;
">
📈 ${pl}%
</span>
`;
}
//END function processRow(row)
function updateAll() {
getRows().forEach(
processRow
);
}
document.addEventListener(
'click',
function (e) {
if (!e.shiftKey) return;
const link =
e.target.closest(
'a[href*="/charts/content/symbols/"]'
);
if (!link)
return;
const symbol =
link.textContent.trim();
const oldValue =
getCost(symbol) || '';
const value =
prompt(
`Nhập giá vốn ${symbol}`,
oldValue
);
if (
value === null ||
value === ''
) return;
setCost(
symbol,
value
);
updateAll();
}
);
setInterval(
updateAll,
2000
);
updateAll();
})();
//END document.addEventListener('click'
Cách dùng
🔹 Mở Watchlist trên FireAnt
🔹 Bấm vào ⚙️:
MSB
🔹 Nhập:
13.5
🔹 Kết quả:
MSB
14.60
💰 13.50
📈 +8.15%Nâng cấp tiếp theo
Phiên bản 2 tôi có thể bổ sung:
✅ Số lượng cổ phiếu
✅ Lãi/lỗ bằng tiền
✅ Tổng NAV danh mục
✅ Export / Import JSON
✅ Đồng bộ nhiều watchlist
✅ Panel nổi bên phải giống màn hình CTCK






Không có nhận xét nào:
Đăng nhận xét