Userscripts

These add any video you watch on these sites to Pornvid.

txxx.com

txxx.com.user.js
// ==UserScript==
// @name        txxx.com copy
// @namespace   Violentmonkey Scripts
// @match       https://txxx.com/*
// @grant       none
// @version     1.0
// @author      -
// @description 6/18/2022, 11:06:57 PM
// ==/UserScript==
var isredirect=true;
//The script matches all pages but only properly runs on a real video to make it easy to toggle the script from other pages
if(location.pathname.startsWith('/videos/')) {
  runonmatch();
}
function addbutton() {
  var body=document.body;
  var targetadd=body
  var button=document.createElement('button');
  button.innerText='Copy to p.gvid.tv';
  //button.style.position="absolute";
  button.style.zIndex="5";
  button.style.width="15em";
  button.style.left="15em";
  button.style.color='black';
  targetadd.prepend(button);
  button.addEventListener('click',()=>{
   postit(alert);
   button.style.color="gray";
  });
}
window.getmeta=getmeta;
function getmeta(cb) {
  var tag=parseInt(location.pathname.split('/')[2]);
  var metaurl=`https://txxx.com/api/json/video/86400/${Math.floor(tag/1000000)*1000000}/${Math.floor(tag/1000)*1000}/${tag}.json`;
  fetch(metaurl).then(resp=>resp.json()).then(meta=>{
   meta=meta.video;
   var title=meta.title;
   var duration=meta.duration;
   duration=duration.split(':').map(i=>parseFloat(i)).reverse().reduce((a,b,i)=>a+b*Math.pow(60,i)); //Convert to seconds
   var thumburl=meta.thumbsrc;
   var embedurl='https://txxx.com/embed/'+tag+'/';
   var user='txxx';
   cb(null,{title,thumburl,duration,embedurl,user});  
  }).catch(cb);
}
function postit(cb) {
 getmeta((err,meta)=>{
   if(err) return cb(err);
   fetch('https://p.gvid.tv/copypost',{method:'POST',body:JSON.stringify(meta)}).then(r=>r.text()).then(tag=>cb(null,tag)).catch(cb);
 });
}
function runonmatch() {
  if(isredirect) {
   postit((err,newtag)=>{
    if(err) return alert(err);
    window.location='https://p.gvid.tv/v/'+newtag;
   });
  }
  addbutton();
}

porntrex.com

porntrex.com.user.js
// ==UserScript==
// @name        porntrex.com copy
// @namespace   Violentmonkey Scripts
// @match       https://www.porntrex.com/*
// @grant       none
// @version     1.0
// @author      -
// @description 6/18/2022, 11:06:57 PM
// ==/UserScript==
if(location.pathname.startsWith('/video/')) {
  doscript();
}
function doscript() {
  var isredirect=true;
  var tag=location.pathname.split('/').slice(-2).join('/');
  var pvidpath='https://p.gvid.tv/copytrex/'+tag;
  if(isredirect) {
   postit((err,newtag)=>{
    if(err) return alert(err);
    window.location='https://p.gvid.tv/v/'+newtag;
   });
  }
  var topnav=document.querySelector('.top-nav .container');
  var body=document.body;
  var targetadd=topnav;
  var button=document.createElement('button');
  button.innerText='Copy to p.gvid.tv';
  //button.style.position="absolute";
  button.style.zIndex="5";
  button.style.width="15em";
  button.style.left="15em";
  button.style.color='black';
  targetadd.prepend(button);
  button.addEventListener('click',()=>{
   fetch(pvidpath);
   button.style.color="gray";
  });
  function postit(cb) {
   fetch(pvidpath).then(resp=>resp.text()).then(newtag=>cb(null,newtag)).catch(cb);
  }
}

xvideos.com

xvideos.com.user.js
// ==UserScript==
// @name        xvideos.com copy
// @namespace   Violentmonkey Scripts
// @match       https://xvideos.com/*
// @match       https://www.xvideos.com/*
// @grant       none
// @version     1.0
// @author      -
// @description 6/18/2022, 11:06:57 PM
// @grant       GM_xmlhttpRequest
// ==/UserScript==
var isredirect=true;
if(location.pathname.startsWith('/video')) {
  runonmatch();
}

function addbutton() {
  var body=document.body;
  var targetadd=body
  var button=document.createElement('button');
  button.innerText='Copy to p.gvid.tv';
  //button.style.position="absolute";
  button.style.zIndex="5";
  button.style.width="15em";
  button.style.left="15em";
  button.style.color='black';
  targetadd.prepend(button);
  button.addEventListener('click',()=>{
   postit2(alert);
   button.style.color="gray";
  });
}
getmeta(console.log);
window.getmeta=getmeta;
function getmeta(cb) {
  var tag=parseInt(location.pathname.split('/')[1].replace('video',''));
  var title=document.title;
  var duration=parseInt(document.head.querySelector('meta[property="og:duration"]').content);
  var thumburl=document.head.querySelector('meta[property="og:image"]').content
  var embedurl='https://xvideos.com/embedframe/'+tag;
  var user='xvideos';
  cb(null,{title,thumburl,duration,embedurl,user});
}
function postit(cb) {
 getmeta((err,meta)=>{
   if(err) return cb(err);
   fetch('https://p.gvid.tv/copypost',{method:'POST',body:JSON.stringify(meta)}).then(r=>r.text()).then(tag=>cb(null,tag)).catch(cb);
 });
}

function postit2(cb) {
 getmeta((err,meta)=>{
  if(err) return cb(err);
  var ctrl=GM_xmlhttpRequest({url:'https://p.gvid.tv/copypost',method:'POST',data:JSON.stringify(meta)});
  ctrl.onerror=resp=>{
   alert('failed');
  };
  ctrl.onload=resp=>{
   cb(null,resp.responseText);
  };
 });
}


function runonmatch() {
  if(isredirect) {
   postit2((err,newtag)=>{
    if(err) return alert(err);
    window.location='https://p.gvid.tv/v/'+newtag;
   });
  }
  addbutton();
}