// ==UserScript==
// @name Pump.fun Price Monitor
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Monitor cryptocurrency prices on pump.fun
// @author Your Name
// @match https://pump.fun/*
// @match https://www.pump.fun/*
// @grant none
// @run-at document-idle
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Configuration
const TARGET_PRICE = 0.1; // Change this to your desired target price (in appropriate units)
const CHECK_INTERVAL = 2000; // Check every 2 seconds (less aggressive)
let isMonitoring = false;
let monitoringInterval = null;
// Wait for page to fully load
function waitForPageLoad() {
return new Promise((resolve) => {
if (document.readyState === 'complete') {
resolve();
} else {
window.addEventListener('load', resolve);
}
});
}
// Function to find price element (you'll need to adjust these selectors)
function getCurrentPrice() {
// Common selectors that might contain price info on pump.fun
const possibleSelectors = [
'[data-testid*="price"]',
'.price',
'[class*="price"]',
'.market-cap',
'[class*="market"]',
'.token-price',
'[data-price]'
];
for (const selector of possibleSelectors) {
const element = document.querySelector(selector);
if (element && element.textContent) {
const text = element.textContent.trim();
const priceMatch = text.match(/[\d,]+\.?\d*/);
if (priceMatch) {
return parseFloat(priceMatch[0].replace(/,/g, ''));
}
}
}
return null;
}
// Function to check if target price is reached
function checkPrice() {
try {
const currentPrice = getCurrentPrice();
if (currentPrice !== null) {
console.log(`Current price: ${currentPrice}`);
if (currentPrice >= TARGET_PRICE) {
handlePriceTarget(currentPrice);
}
} else {
console.log('Could not find price element');
}
} catch (error) {
console.error('Error checking price:', error);
}
}
// Function called when target price is reached
function handlePriceTarget(price) {
console.log(`Target price reached! Current: ${price}, Target: ${TARGET_PRICE}`);
// Stop monitoring to prevent multiple alerts
stopMonitoring();
// Show alert
if (confirm(`Price target reached: ${price}! Do you want to take action?`)) {
// Add your action logic here
// For example: window.open('https://pump.fun/sell', '_blank');
console.log('User confirmed action');
}
}
// Start monitoring
function startMonitoring() {
if (!isMonitoring) {
isMonitoring = true;
monitoringInterval = setInterval(checkPrice, CHECK_INTERVAL);
console.log('Price monitoring started');
}
}
// Stop monitoring
function stopMonitoring() {
if (isMonitoring && monitoringInterval) {
clearInterval(monitoringInterval);
isMonitoring = false;
monitoringInterval = null;
console.log('Price monitoring stopped');
}
}
// Add control panel to page
function addControlPanel() {
const panel = document.createElement('div');
panel.id = 'price-monitor-panel';
panel.style.cssText = `
position: fixed;
top: 10px;
right: 10px;
background: #1a1a1a;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 10000;
font-family: Arial, sans-serif;
font-size: 12px;
box-shadow: 0 2px 10px rgba(0,0,0,0.3);
`;
panel.innerHTML = `
Price Monitor
Target: ${TARGET_PRICE}
Start
Stop
Price: --
`;
document.body.appendChild(panel);
// Add event listeners
document.getElementById('start-monitor').addEventListener('click', startMonitoring);
document.getElementById('stop-monitor').addEventListener('click', stopMonitoring);
// Update current price display
setInterval(() => {
const price = getCurrentPrice();
const priceDisplay = document.getElementById('current-price');
if (priceDisplay) {
priceDisplay.textContent = `Price: ${price !== null ? price : '--'}`;
}
}, 1000);
}
// Initialize script
async function init() {
try {
await waitForPageLoad();
// Wait a bit more for dynamic content to load
setTimeout(() => {
addControlPanel();
console.log('Pump.fun price monitor loaded');
}, 2000);
} catch (error) {
console.error('Error initializing script:', error);
}
}
// Start the script
init();
})();