pornhub.com playlist link grabber for /view_video

This adds a button to pornhub video player page if the video is part of a playlist to grab links to all videos in said playlist

  1. // ==UserScript==
  2. // @name pornhub.com playlist link grabber for /view_video
  3. // @description This adds a button to pornhub video player page if the video is part of a playlist to grab links to all videos in said playlist
  4. // @version 1.0.0
  5. // @license MIT
  6. // @match https://*.pornhub.com/view_video.php*
  7. // @match https://*.pornhubpremium.com/view_video.php*
  8. // @namespace https://sleazyfork.org/users/179893
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var playlistBar = document.querySelector('.playlist-bar');
  15. if(playlistBar) {
  16. var btnContainer = playlistBar.querySelector('#prevButton').parentNode;
  17.  
  18. var linkGrabberBtn = document.createElement('div');
  19. linkGrabberBtn.onclick = grabVideoList;
  20. linkGrabberBtn.classList.add('orangeButton');
  21. linkGrabberBtn.style.cssFloat = 'left';
  22. linkGrabberBtn.style.marginRight = '20px';
  23. var span = document.createElement('span');
  24. span.innerText = 'Get all video links';
  25. span.className = 'text';
  26. linkGrabberBtn.appendChild(span);
  27. btnContainer.prepend(linkGrabberBtn);
  28. }
  29.  
  30. function grabVideoList(){
  31. var links = playlistBar.querySelectorAll('.video-box-playlist a');
  32. showLinks(links);
  33. }
  34.  
  35. function showLinks(linkList) {
  36. var outerModalDiv = document.createElement('div');
  37. var innerModalDiv = document.createElement('div');
  38. outerModalDiv.id = 'playlist213VidsLinkContainingModalPanel'; //use a long id to avoid name conflicts
  39. outerModalDiv.style.display = 'block';
  40. outerModalDiv.style.position = 'fixed';
  41. outerModalDiv.style.zIndex = '100';
  42. outerModalDiv.style.paddingTop = '100px';
  43. outerModalDiv.style.left = '0';
  44. outerModalDiv.style.top = '0';
  45. outerModalDiv.style.width = '100%';
  46. outerModalDiv.style.height = '100%';
  47. outerModalDiv.style.overflow = 'auto';
  48. outerModalDiv.style.backgroundColor = 'rgb(0,0,0)';
  49. outerModalDiv.style.backgroundColor = 'rgb(0,0,0,0.4)';
  50.  
  51. //add close btn
  52. var closeButtonContainer = document.createElement('div');
  53. closeButtonContainer.className = 'userButtons';
  54. var closeButton = CreateButton('X', null, RemoveOuterModalPanel);
  55. closeButton.style.cssFloat = 'right';
  56. closeButtonContainer.appendChild(closeButton);
  57. innerModalDiv.appendChild(closeButtonContainer);
  58.  
  59.  
  60. innerModalDiv.style.backgroundColor = '#1b1b1b';
  61. innerModalDiv.style.margin = 'auto';
  62. innerModalDiv.style.padding = '20px';
  63. innerModalDiv.style.border = '1px solid #888';
  64. innerModalDiv.style.width = '80%';
  65. innerModalDiv.style.color = '#ababab';
  66.  
  67. var instructions1 = document.createElement('p');
  68. var instructions2 = document.createElement('p');
  69. var instructions3 = document.createElement('p');
  70.  
  71. instructions1.innerHTML = 'Save the links to a local textfile (e.g. &quotC:\\Temp\\dl\\linklist.txt)&quot and run youtube-dl whith the -a argument and the path to the linklist.';
  72. instructions2.innerHTML = 'youtube-dl -a &quotC:\\Temp\\dl\\linklist.txt&quot';
  73. instructions3.innerHTML = 'Or just use jDownloader with the linklist';
  74.  
  75. innerModalDiv.appendChild(instructions1);
  76. innerModalDiv.appendChild(instructions2);
  77. innerModalDiv.appendChild(instructions3);
  78.  
  79.  
  80. var linkListDiv;
  81.  
  82. linkListDiv = document.createElement('div');
  83.  
  84.  
  85. for (var i = 0; i < linkList.length; i++) {
  86. var a = document.createElement('a');
  87. var p = document.createElement('p');
  88. p.innerHTML = linkList[i].href;
  89. a.href = linkList[i].href;
  90. a.download = linkList[i].title;
  91. a.appendChild(p);
  92. linkListDiv.appendChild(a);
  93. }
  94. innerModalDiv.appendChild(linkListDiv);
  95. outerModalDiv.appendChild(innerModalDiv);
  96. document.body.appendChild(outerModalDiv);
  97. }
  98.  
  99.  
  100. function CreateButton(text, id, onClickEvent) {
  101. var innerbutton = document.createElement('button');
  102. innerbutton.innerText = text;
  103. innerbutton.className = 'buttonBase';
  104. innerbutton.style.backgroundColor = '#f90';
  105. innerbutton.style.color = '#000';
  106. innerbutton.style.fontWeight = '700';
  107. innerbutton.display = 'inline-block';
  108.  
  109. var button = document.createElement('div');
  110. if (id) button.id = id;
  111.  
  112. button.style.padding = '5px 10px';
  113. button.style.lineHeight = '1.2em';
  114. button.style.borderRadius = '4px';
  115. button.onclick = onClickEvent;
  116. button.appendChild(innerbutton);
  117. return button;
  118. }
  119.  
  120. function RemoveOuterModalPanel() {
  121. var toRemove = document.getElementById('playlist213VidsLinkContainingModalPanel');
  122. toRemove.parentNode.removeChild(toRemove);
  123. }
  124.  
  125. })();