Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Stealthgram Profile Link & Clipboard Tools
- // @namespace https://stealthgram.com/
- // @version 1.1
- // @description Inserts profile link, copy buttons, and notifications under profile on Stealthgram post pages, even if DOM reloads dynamically
- // @author OpenAI Perplexity
- // @match https://stealthgram.com/media/*
- // @grant GM_setClipboard
- // @run-at document-end
- // ==/UserScript==
- (function() {
- 'use strict';
- // Toast notification creator
- function showToast(msg) {
- let toast = document.createElement("div");
- toast.textContent = msg;
- toast.style.position = "fixed";
- toast.style.bottom = "32px";
- toast.style.left = "50%";
- toast.style.transform = "translateX(-50%)";
- toast.style.background = "rgba(30,30,30,0.98)";
- toast.style.color = "white";
- toast.style.padding = "12px 32px";
- toast.style.fontSize = "1rem";
- toast.style.borderRadius = "16px";
- toast.style.zIndex = 99999;
- toast.style.boxShadow = "0 4px 32px #000a";
- toast.style.fontWeight = "500";
- document.body.appendChild(toast);
- setTimeout(() => {toast.remove();}, 1800);
- }
- // Insert tools if profile header exists
- function insertTools() {
- const h = document.querySelector('h5.header');
- if (!h) return false;
- let profileName = h.textContent.trim();
- if (!profileName) return false;
- let profileUrl = `https://stealthgram.com/profile/${profileName}`;
- let m = window.location.pathname.match(/\/media\/([^\/?#]+)/);
- if (!m) return false;
- let postId = m[1];
- let filename = `instagram_p_${postId} by ${profileName}`;
- // Prevent adding twice
- if (h.parentNode.querySelector('.stealth-profiletools')) return true;
- let container = document.createElement('div');
- container.className = 'stealth-profiletools';
- container.style.marginTop = '10px';
- container.style.display = 'flex';
- container.style.alignItems = 'center';
- container.style.gap = '10px';
- // Profile link
- let a = document.createElement('a');
- a.href = profileUrl;
- a.textContent = profileUrl;
- a.target = '_blank';
- a.style.color = '#1da1f2';
- a.style.fontSize = '1rem';
- a.style.textDecoration = 'underline';
- container.appendChild(a);
- // Copy link button
- let btnClipboard = document.createElement('button');
- btnClipboard.textContent = '📋';
- btnClipboard.title = 'Copy profile link';
- btnClipboard.style.cursor = 'pointer';
- btnClipboard.style.border = 'none';
- btnClipboard.style.background = 'transparent';
- btnClipboard.style.fontSize = '1.2em';
- btnClipboard.onclick = function() {
- if (typeof GM_setClipboard === "function") {
- GM_setClipboard(profileUrl);
- } else {
- navigator.clipboard.writeText(profileUrl);
- }
- showToast('Profile link copied!');
- };
- container.appendChild(btnClipboard);
- // Copy filename button
- let btnFilename = document.createElement('button');
- btnFilename.textContent = 'Filename';
- btnFilename.title = 'Copy filename';
- btnFilename.style.cursor = 'pointer';
- btnFilename.style.border = '1px solid #bbb';
- btnFilename.style.background = 'white';
- btnFilename.style.borderRadius = '7px';
- btnFilename.style.fontSize = '0.95em';
- btnFilename.style.marginLeft = '6px';
- btnFilename.onclick = function() {
- if (typeof GM_setClipboard === "function") {
- GM_setClipboard(filename);
- } else {
- navigator.clipboard.writeText(filename);
- }
- showToast('Filename copied!');
- };
- container.appendChild(btnFilename);
- h.parentNode.insertBefore(container, h.nextSibling);
- return true;
- }
- // Timed retries (for slow loading)
- let tries = 0;
- let maxTries = 40;
- function tryInsertTools() {
- if (!insertTools() && (++tries < maxTries)) {
- setTimeout(tryInsertTools, 100);
- }
- }
- tryInsertTools();
- // MutationObserver (for dynamic DOM reloads)
- const observer = new MutationObserver(() => {
- insertTools();
- });
- observer.observe(document.body, { childList: true, subtree: true });
- })();
Advertisement
Add Comment
Please, Sign In to add comment