Youtube内容分享到QQ空间

分享YouTube视频到QQ空间

  1. // ==UserScript==
  2. // @name Youtube内容分享到QQ空间
  3. // @namespace https://www.deginx.com
  4. // @version 1.2
  5. // @description 分享YouTube视频到QQ空间
  6. // @author Jonyan Dunh
  7. // @qq 1309634881
  8. // @copyright DEGINX
  9. // @homepage https://www.deginx.com
  10. // @match *://*.youtube.com/*
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. if (document.getElementById("polymer-app") || document.getElementById("masthead") || window.Polymer) {
  15. setInterval(function() {
  16. if (window.location.href.indexOf("watch?v=") < 0) {
  17. return false;
  18. }
  19. if (document.getElementById("count") && document.getElementById("bitdownloader") === null) {
  20. polymerAdd();
  21. }
  22. }, 100);
  23. } else {
  24. setInterval(function() {
  25. if (window.location.href.indexOf("watch?v=") < 0) {
  26. return false;
  27. }
  28. if (document.getElementById("watch7-subscription-container") && document.getElementById("bitdownloader") === null) {
  29. htmlAdd();
  30. }
  31. }, 100);
  32. }
  33.  
  34. function htmlAdd() {
  35. if (document.getElementById("watch7-subscription-container")) {
  36. var wrap = document.getElementById('watch7-subscription-container');
  37. var button = "<div id='bitdownloader' style='display: inline-block; margin-left: 10px; vertical-align: middle;'>";
  38. button += '<a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(window.location.href)+'&title='+document.title+'&desc=//'+document.title+'&summary='+document.querySelector('yt-formatted-string.ytd-video-secondary-info-renderer').innerText.substring(0,70)+'&site=youtube.com&pics=https://api.deginx.com/youtube-cover.php?video_id='+ytvid(document.URL)+ "\" title=\"Download this video\" target=\"_blank\"" +
  39. "style=\"display: inline-block; font-size: inherit; height: 22px; border: 1px solid rgb(0, 183, 90); border-radius: 5px; padding-left: 28px; cursor: pointer; vertical-align: middle; position: relative; line-height: 22px; text-decoration: none; z-index: 1; color: rgb(255, 255, 255);\">";
  40. button += "<i style=\"position: absolute; display: inline-block; left: 6px; top: 3px; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIiB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIGlkPSJzdmcyIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJNIDQsMCA0LDggMCw4IDgsMTYgMTYsOCAxMiw4IDEyLDAgNCwwIHoiIGZpbGw9IiNmZmZmZmYiIC8+PC9zdmc+); background-size: 12px; background-repeat: no-repeat; background-position: center center; width: 16px; height: 16px;\"></i>";
  41. button += "<span style=\"padding-right: 12px;\">Download</span></a></div>";
  42. var style = "<style>#bitdownloader button::-moz-focus-inner{padding:0;margin:0}#bitdownloader a{background-color:#15388c}#bitdownloader a:hover{background-color:#E91E63}#bitdownloader a:active{background-color:rgb(0, 151, 74)}</style>";
  43. var tmp = wrap.innerHTML;
  44. wrap.innerHTML = tmp + button + style;
  45. }
  46. }
  47.  
  48. function polymerAdd() {
  49. var buttonDiv = document.createElement("span");
  50. buttonDiv.style.width = "100%";
  51. buttonDiv.id = "bitdownloader";
  52. var addButton = document.createElement("a");
  53. addButton.appendChild(document.createTextNode("分享到QQ空间"));
  54. addButton.style.width = "100%";
  55. addButton.style.backgroundColor = "#ccc235";
  56. // #15388c
  57. addButton.style.color = "white";
  58. addButton.style.textAlign = "center";
  59. addButton.style.padding = "5px 10px";
  60. addButton.style.margin = "0px 10px";
  61. addButton.style.fontSize = "14px";
  62. addButton.style.border = "0";
  63. addButton.style.cursor = "pointer";
  64. addButton.style.borderRadius = "2px";
  65. addButton.style.fontFamily = "Roboto, Arial, sans-serif";
  66. addButton.style.textDecoration = "none";
  67. addButton.href = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(window.location.href)+'&title='+document.title+'&desc=//'+document.title+'&summary='+document.querySelector('yt-formatted-string.ytd-video-secondary-info-renderer').innerText.substring(0,100)+'&site=youtube.com&pics=https://api.deginx.com/youtube-cover.php?video_id='+ytvid(document.URL);
  68. addButton.target = "_blank";
  69. buttonDiv.appendChild(addButton);
  70. var targetElement = document.querySelectorAll("[id='count']");
  71. for (var i = 0; i < targetElement.length; i++) {
  72. if (targetElement[i].className.indexOf("ytd-video-primary-info-renderer") > -1) {
  73. targetElement[i].appendChild(buttonDiv);
  74. }
  75. }
  76. }
  77.  
  78. function ytvid(url) {
  79. var p = /((http|https)\:\/\/)?(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig;
  80. return (url.match(p)) ? RegExp.$3 : false;
  81. }
  82.  
  83. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址