2024-12-18 22:01:02 +00:00
|
|
|
document.getElementById('fetchBtn').addEventListener('click', () => {
|
2024-12-18 21:21:37 +00:00
|
|
|
const urlInput = document.getElementById('pasteUrl').value;
|
2024-12-18 22:01:02 +00:00
|
|
|
|
|
|
|
// Extract the Paste ID from the provided Pastebin URL
|
|
|
|
const pasteId = getPasteId(urlInput);
|
|
|
|
|
|
|
|
if (pasteId) {
|
2024-12-18 22:04:00 +00:00
|
|
|
window.location.href = `/${pasteId}`;
|
2024-12-18 22:01:02 +00:00
|
|
|
} else {
|
|
|
|
alert('Please enter a valid Pastebin URL.');
|
|
|
|
}
|
2024-12-18 21:21:37 +00:00
|
|
|
});
|
2024-12-18 22:01:02 +00:00
|
|
|
|
|
|
|
function getPasteId(url) {
|
|
|
|
// Check if the URL is a valid Pastebin URL and extract the Paste ID
|
|
|
|
const regex = /pastebin\.com\/(?:raw\/)?([a-zA-Z0-9]+)/;
|
|
|
|
const match = url.match(regex);
|
|
|
|
|
|
|
|
if (match) {
|
|
|
|
return match[1]; // Return the Paste ID
|
|
|
|
}
|
|
|
|
return null; // Invalid Pastebin URL
|
|
|
|
}
|