Guest User

Untitled

a guest
Aug 6th, 2025
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Stealthgram Profile Link & Clipboard Tools
  3. // @namespace    https://stealthgram.com/
  4. // @version      1.0
  5. // @description  Inserts profile link, copy buttons, and notifications under profile on Stealthgram post pages
  6. // @author       OpenAI Perplexity
  7. // @match        https://stealthgram.com/media/*
  8. // @grant        GM_setClipboard
  9. // @run-at       document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.   'use strict';
  14.  
  15.   // Toast notification creator
  16.   function showToast(msg) {
  17.     let toast = document.createElement("div");
  18.     toast.textContent = msg;
  19.     toast.style.position = "fixed";
  20.     toast.style.bottom = "32px";
  21.     toast.style.left = "50%";
  22.     toast.style.transform = "translateX(-50%)";
  23.     toast.style.background = "rgba(30,30,30,0.98)";
  24.     toast.style.color = "white";
  25.     toast.style.padding = "12px 32px";
  26.     toast.style.fontSize = "1rem";
  27.     toast.style.borderRadius = "16px";
  28.     toast.style.zIndex = 99999;
  29.     toast.style.boxShadow = "0 4px 32px #000a";
  30.     toast.style.fontWeight = "500";
  31.     document.body.appendChild(toast);
  32.     setTimeout(() => {toast.remove();}, 1800);
  33.   }
  34.  
  35.   // Wait until the profile header exists (for sites that load content dynamically)
  36.   function insertTools() {
  37.     const h = document.querySelector('h5.header');
  38.     if (!h) return false;
  39.  
  40.     let profileName = h.textContent.trim();
  41.     let profileUrl = `https://stealthgram.com/profile/${profileName}`;
  42.     let m = window.location.pathname.match(/\/media\/([^\/?#]+)/);
  43.     if (!m) return false;
  44.     let postId = m[1];
  45.     let filename = `instagram_p_${postId} by ${profileName}`;
  46.  
  47.     // Prevent adding twice
  48.     if (h.parentNode.querySelector('.stealth-profiletools')) return true;
  49.  
  50.     let container = document.createElement('div');
  51.     container.className = 'stealth-profiletools';
  52.     container.style.marginTop = '10px';
  53.     container.style.display = 'flex';
  54.     container.style.alignItems = 'center';
  55.     container.style.gap = '10px';
  56.  
  57.     // Profile link
  58.     let a = document.createElement('a');
  59.     a.href = profileUrl;
  60.     a.textContent = profileUrl;
  61.     a.target = '_blank';
  62.     a.style.color = '#1da1f2';
  63.     a.style.fontSize = '1rem';
  64.     a.style.textDecoration = 'underline';
  65.     container.appendChild(a);
  66.  
  67.     // Copy link button (clipboard)
  68.     let btnClipboard = document.createElement('button');
  69.     btnClipboard.textContent = '📋';
  70.     btnClipboard.title = 'Copy profile link';
  71.     btnClipboard.style.cursor = 'pointer';
  72.     btnClipboard.style.border = 'none';
  73.     btnClipboard.style.background = 'transparent';
  74.     btnClipboard.style.fontSize = '1.2em';
  75.     btnClipboard.onclick = function(){
  76.       if (typeof GM_setClipboard === "function") {
  77.         GM_setClipboard(profileUrl);
  78.       } else {
  79.         navigator.clipboard.writeText(profileUrl);
  80.       }
  81.       showToast('Profile link copied!');
  82.     };
  83.     container.appendChild(btnClipboard);
  84.  
  85.     // Copy filename button
  86.     let btnFilename = document.createElement('button');
  87.     btnFilename.textContent = 'Filename';
  88.     btnFilename.title = 'Copy filename';
  89.     btnFilename.style.cursor = 'pointer';
  90.     btnFilename.style.border = '1px solid #bbb';
  91.     btnFilename.style.background = 'white';
  92.     btnFilename.style.borderRadius = '7px';
  93.     btnFilename.style.fontSize = '0.95em';
  94.     btnFilename.style.marginLeft = '6px';
  95.     btnFilename.onclick = function(){
  96.       if (typeof GM_setClipboard === "function") {
  97.         GM_setClipboard(filename);
  98.       } else {
  99.         navigator.clipboard.writeText(filename);
  100.       }
  101.       showToast('Filename copied!');
  102.     };
  103.     container.appendChild(btnFilename);
  104.  
  105.     h.parentNode.insertBefore(container, h.nextSibling);
  106.  
  107.     showToast('Profile tools inserted.');
  108.     return true;
  109.   }
  110.  
  111.   // Hook for dynamic sites (try for a few seconds)
  112.   let tries = 0;
  113.   let maxTries = 40; // Try for 4s max (100ms steps)
  114.   function tryInsertTools() {
  115.     if (!insertTools() && (++tries < maxTries)) {
  116.       setTimeout(tryInsertTools, 100);
  117.     }
  118.   }
  119.   tryInsertTools();
  120. })();
  121.  
Advertisement
Add Comment
Please, Sign In to add comment