Guest User

Untitled

a guest
Sep 27th, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function() {     let currentElement = null;     let notifications = [];     const maxNotifications = 3;      function handleClick(event) {         event.preventDefault();         event.stopPropagation();          if (currentElement) {             currentElement.classList.remove('highlight');         }          currentElement = event.target;         currentElement.classList.add('highlight');          navigator.clipboard.writeText(currentElement.outerHTML)             .then(() => {                 console.log("HTML copied to clipboard");                 showNotification("HTML copied to clipboard. Press Q or ESC to exit.");             })             .catch(err => console.error("Could not copy text: ", err));     }      function handleKeyPress(event) {         if (event.key === 'q' || event.key === 'Escape') {             document.body.removeEventListener('click', handleClick);             document.body.removeEventListener('keydown', handleKeyPress);              if (currentElement) {                 currentElement.classList.remove('highlight');                 currentElement = null;             }              const notificationStyle = document.querySelector('style.notification-style');             if (notificationStyle) {                 notificationStyle.remove();             }              const notificationsList = document.querySelectorAll('.notification');             notificationsList.forEach(notification => notification.remove());              notifications.length = 0;             showNotification("Bookmarklet exited. Press Q or ESC to exit next time.");             setTimeout(() => {                 const exitNotification = document.querySelector('.notification');                 if (exitNotification) {                     exitNotification.remove();                 }             }, 2000);         }     }      function showNotification(message) {         const notification = document.createElement('div');         notification.textContent = message;         notification.className = 'notification';          notifications.push(notification);         if (notifications.length > maxNotifications) {             const oldestNotification = notifications.shift();             oldestNotification.remove();         }          document.body.appendChild(notification);          const notificationHeight = notification.offsetHeight;         const bottomOffset = (notifications.length - 1) * notificationHeight;         notification.style.bottom = `${bottomOffset}px`;          const existingStyle = document.querySelector('style.notification-style');         if (!existingStyle) {             const style = document.createElement('style');             style.className = 'notification-style';             style.textContent = `                 .highlight {                     border: 2px solid red;                     box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);                 }                 .notification {                     position: fixed;                     left: 10px;                     bottom: 10px;                     background-color: #fff;                     border: 1px solid #ddd;                     padding: 5px;                     width: 200px;                     z-index: 1000;                     box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);                 }             `;             document.head.appendChild(style);         }     }      document.body.addEventListener('click', handleClick);     document.body.addEventListener('keydown', handleKeyPress);      showNotification("Click an element to copy its HTML. Press Q or ESC to exit."); })();
Advertisement
Add Comment
Please, Sign In to add comment