TinyChan

New reply in topic: Random discussions thread

You are not recognized as the original poster of this topic.

:

You are required to fill in a captcha for your first 5 posts. Sorry, but this is required to stop people from posting while drunk. Please be responsible and don't drink and post!
If you receive this often, consider not clearing your cookies.

Please familiarise yourself with the rules and markup syntax before posting.


Replying to Anonymous…

Extract archived Invidious video info details (for tab hoarders):
if(/^archive\.(ph|is|today|li|fo|vn|md)$/i.test(window.location.hostname)){
  document.querySelector("video#player_html5_api[autoplay]")?.remove(); //remove non-functional video overlay obscuring the title
  let channelName=document.getElementById('channel-name').innerText.replace(/\xA0\uF2BB$/,""),videoTitle=document.querySelector("h1").innerText.replace(/ \uF306$/,""),formatTime=time=>{
    let date=new Date(time.getAttribute("datetime")),
        str=date.toLocaleDateString("en-GB",{day:"numeric",month:"short"});
    if(date.getFullYear()!==new Date().getFullYear()) //not from this year?
      str+=" "+date.getFullYear();
    return str;
  },pubDate=formatTime(document.querySelector("time[itemprop='pubdate']")),searchBar=document.querySelector("input[name='q']"), //AKA "form[action*='search'] input[value]"
      videoID=(()=>{if(searchBar.value&&searchBar.value.includes("watch?v="))return"v="+(new URL(searchBar.value).searchParams.get("v"));})(),
      archiveID=new URL(window.location.href).pathname.split("/").find(x=>x);
  console.log(videoID);
  searchBar.value=JSON.stringify(`[YT] ${channelName} “${videoTitle}” (${pubDate}:${archiveID}${videoID!==undefined?", "+videoID:""})`);
}

As a bookmarklet:
javascript:(function(){if(/^archive\.(ph|is|today|li|fo|vn|md)$/i.test(location.hostname)){document.querySelector("video#player_html5_api[autoplay]")?.remove();var c=document.getElementById('channel-name').innerText.replace(/\xA0\uF2BB$/,""),v=document.querySelector("h1").innerText.replace(/ \uF306$/,""),f=t=>{var d=new Date(t.getAttribute("datetime")),s=d.toLocaleDateString("en-GB",{day:"numeric",month:"short"});return d.getFullYear()!==new Date().getFullYear()&&(s+=" "+d.getFullYear()),s},p=f(document.querySelector("time[itemprop='pubdate']")),s=document.querySelector("input[name='q']"),i=s.value&&s.value.includes("watch?v=")?"v="+new URL(s.value).searchParams.get("v"):void 0,a=location.pathname.split("/").find(x=>x);s.value=JSON.stringify(`[YT] ${c} “${v}” (${p}:${a}${i?`, ${i}`:""})`);}})();