Guest User

Untitled

a guest
Aug 24th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function(){
  2.  
  3.     function absoluteUrl(h){try{return new URL(h,window.location.origin).href}catch(e){return h||''}}
  4.  
  5.     function getText(sel){var el=document.querySelector(sel);return el?el.textContent.trim():'N/A'}
  6.  
  7.     function getDescriptionBBCode(){
  8.  
  9.         var container=document.querySelector('div[data-e2e="browse-video-desc"]'); if(!container) return 'N/A';
  10.  
  11.         var parts=[];
  12.  
  13.         container.childNodes.forEach(function(node){
  14.  
  15.             if(node.nodeType===Node.TEXT_NODE){var t=node.textContent.replace(/\s+/g,' ').trim(); if(t) parts.push(t);}
  16.  
  17.             else if(node.nodeType===Node.ELEMENT_NODE){
  18.  
  19.                 if(node.matches && node.matches('a[data-e2e="search-common-link"]')){
  20.  
  21.                     parts.push('[u][url='+absoluteUrl(node.getAttribute('href'))+']'+node.textContent.trim()+'[/url][/u]');
  22.  
  23.                 } else {
  24.  
  25.                     var anchors = node.querySelectorAll && node.querySelectorAll('a[data-e2e="search-common-link"]');
  26.  
  27.                     if(anchors && anchors.length){
  28.  
  29.                         var sp=[]; node.childNodes.forEach(function(sn){
  30.  
  31.                             if(sn.nodeType===Node.TEXT_NODE){var s=sn.textContent.replace(/\s+/g,' ').trim(); if(s) sp.push(s)}
  32.  
  33.                             else if(sn.nodeType===Node.ELEMENT_NODE && sn.matches && sn.matches('a[data-e2e="search-common-link"]')) sp.push('[u][url='+absoluteUrl(sn.getAttribute('href'))+']'+sn.textContent.trim()+'[/url][/u]');
  34.  
  35.                             else {var s=sn.textContent.replace(/\s+/g,' ').trim(); if(s) sp.push(s)}
  36.  
  37.                         });
  38.  
  39.                         if(sp.length) parts.push(sp.join(' '));
  40.  
  41.                     } else {
  42.  
  43.                         var t=node.textContent.replace(/\s+/g,' ').trim(); if(t) parts.push(t);
  44.  
  45.                     }
  46.  
  47.                 }
  48.  
  49.             }
  50.  
  51.         });
  52.  
  53.         return parts.join(' ').replace(/\s+/g,' ').trim()||'N/A';
  54.  
  55.     }
  56.  
  57.     function copy(t){var ta=document.createElement('textarea');ta.value=t;ta.style.position='fixed';ta.style.left='-9999px';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta)}
  58.  
  59.     function toast(m){var d=document.createElement('div');Object.assign(d.style,{position:'fixed',top:'10px',right:'10px',padding:'12px 24px',backgroundColor:'#00C851',color:'white',borderRadius:'4px',fontSize:'14px',zIndex:100000,boxShadow:'0 2px 5px rgba(0,0,0,0.2)'});d.textContent=m;document.body.appendChild(d);setTimeout(()=>d.remove(),3000)}
  60.  
  61.     function process(){
  62.  
  63.         var metadata={description:getDescriptionBBCode(), creator:getText('span[data-e2e="browse-username"]'), creatorUrl:absoluteUrl((document.querySelector('a[data-e2e="browse-user-avatar"]')||{}).getAttribute('href')), likes:getText('strong[data-e2e="like-count"], strong[data-e2e="browse-like-count"], strong.css-vc3yj-StrongText'), comments:getText('strong[data-e2e="comment-count"], strong[data-e2e="browse-comment-count"], strong.css-vc3yj-StrongText'), shares:getText('strong[data-e2e="share-count"], strong[data-e2e="browse-share-count"], strong[data-e2e="undefined-count"], strong.css-vc3yj-StrongText')};
  64.  
  65.         var url=window.location.href;
  66.  
  67.         var bb='[b]'+metadata.description+'[/b]\n\n[url='+url+']'+url+'[/url]\n\n[b]Creator Info[/b]\n[u][url='+metadata.creatorUrl+']'+metadata.creator+'[/url][/u]\n\n[b]Engagement[/b]\nLikes: '+metadata.likes+'\nComments: '+metadata.comments+'\nShares: '+metadata.shares;
  68.  
  69.         copy(bb); toast('TikTok data copied');
  70.  
  71.     }
  72.  
  73.     if(window.location.hostname==='www.tiktok.com'){
  74.  
  75.         var btn=document.createElement('button'); btn.textContent='Copy TikTok Data';
  76.  
  77.         Object.assign(btn.style,{position:'fixed',top:'10px',left:'10px',padding:'10px 20px',backgroundColor:'#007BFF',color:'white',border:'none',borderRadius:'4px',cursor:'pointer',zIndex:100000});
  78.  
  79.         btn.addEventListener('click',process); document.body.appendChild(btn);
  80.  
  81.     } else { alert('Please use this bookmarklet on a TikTok video page'); }
  82.  
  83. })();
Advertisement
Add Comment
Please, Sign In to add comment