Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:(function(){
- function absoluteUrl(h){try{return new URL(h,window.location.origin).href}catch(e){return h||''}}
- function getText(sel){var el=document.querySelector(sel);return el?el.textContent.trim():'N/A'}
- function getDescriptionBBCode(){
- var container=document.querySelector('div[data-e2e="browse-video-desc"]'); if(!container) return 'N/A';
- var parts=[];
- container.childNodes.forEach(function(node){
- if(node.nodeType===Node.TEXT_NODE){var t=node.textContent.replace(/\s+/g,' ').trim(); if(t) parts.push(t);}
- else if(node.nodeType===Node.ELEMENT_NODE){
- if(node.matches && node.matches('a[data-e2e="search-common-link"]')){
- parts.push('[u][url='+absoluteUrl(node.getAttribute('href'))+']'+node.textContent.trim()+'[/url][/u]');
- } else {
- var anchors = node.querySelectorAll && node.querySelectorAll('a[data-e2e="search-common-link"]');
- if(anchors && anchors.length){
- var sp=[]; node.childNodes.forEach(function(sn){
- if(sn.nodeType===Node.TEXT_NODE){var s=sn.textContent.replace(/\s+/g,' ').trim(); if(s) sp.push(s)}
- 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]');
- else {var s=sn.textContent.replace(/\s+/g,' ').trim(); if(s) sp.push(s)}
- });
- if(sp.length) parts.push(sp.join(' '));
- } else {
- var t=node.textContent.replace(/\s+/g,' ').trim(); if(t) parts.push(t);
- }
- }
- }
- });
- return parts.join(' ').replace(/\s+/g,' ').trim()||'N/A';
- }
- 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)}
- 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)}
- if(window.location.hostname==='www.tiktok.com'){
- 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')};
- var url=window.location.href;
- 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;
- copy(bb); toast('TikTok data copied');
- } else { alert('Please use this bookmarklet on a TikTok video page'); }
- })();
Advertisement
Add Comment
Please, Sign In to add comment