Videos on CS:GO Stash

Adds videos from CS:GO Skin Showcase (youtube.com/ffffinal) to CS:GO Stash (csgostash.com)

  1. // ==UserScript==
  2. // @name Videos on CS:GO Stash
  3. // @namespace https://github.com/HatScripts/VideosOnCSGOStash
  4. // @version 1.0.3
  5. // @description Adds videos from CS:GO Skin Showcase (youtube.com/ffffinal) to CS:GO Stash (csgostash.com)
  6. // @author HatScripts
  7. // @icon http://csgostash.com/favicon.ico
  8. // @include http*://csgostash.com/*
  9. // @noframes
  10. // ==/UserScript==
  11.  
  12. $(function () {
  13. $.searchVideos = function (query, maxVideos) {
  14. return $.getJSON("https://www.googleapis.com/youtube/v3/search", {
  15. key: "AIzaSyBba67Fu_vuKllOeKXC4v4L4-7GXD93TTs",
  16. part: "snippet",
  17. channelId: "UCBdaeqYDYlS4mxgiemhjRAw",
  18. type: "video",
  19. fields: "items(id/videoId,snippet/title)",
  20. q: query,
  21. maxResults: maxVideos
  22. });
  23. };
  24.  
  25. $.addVideoLinks = function (searchResults) {
  26. resultBoxes.each(function () {
  27. var resultBox = $(this);
  28. var skinName = resultBox.find("h3:first").text().replace(/\\W/, "");
  29. var regex = new RegExp("^(\[Prototype\])?\\W*(?:StatTrak™ )?" + weapon
  30. + "\\W*" + skinName + "\\W*(.+?)?\\W*Skin Showcase$", "i");
  31. var videos = [];
  32.  
  33. searchResults.items.forEach(function (video) {
  34. var groups = regex.exec(video.snippet.title);
  35. if (groups) {
  36. groups.shift();
  37. videos.push({
  38. id: video.id.videoId,
  39. details: groups.filter(function (g) {
  40. return g;
  41. }).join(", ")
  42. });
  43. }
  44. });
  45. videos.sort(function (a, b) {
  46. return a.details.localeCompare(b.details);
  47. }).forEach(function (video) {
  48. $.addVideoLink(resultBox, video.id, video.details);
  49. });
  50. });
  51. };
  52.  
  53. $.addVideoLink = function (resultBox, videoId, details) {
  54. var a = $("<a>", {
  55. href: "https://www.youtube.com/watch?v=" + videoId,
  56. target: "_blank"
  57. }).click(function (e) {
  58. var a = $(this);
  59. a.css("display", "none");
  60. $.embedVideoIn(a.parent(), videoId);
  61. e.preventDefault();
  62. }).append(
  63. $("<span>").addClass("glyphicon glyphicon-film")
  64. ).append("Load Skin Showcase Video");
  65.  
  66. if (details) {
  67. details = details.replace(/ \(|\) /, " - ");
  68. a.append(" (" + details + ")");
  69. }
  70. resultBox.find(".details-link").append(
  71. $("<p>").append(a)
  72. );
  73. };
  74.  
  75. $.embedVideoIn = function (element, videoId) {
  76. element.append(
  77. $("<div>").css({
  78. position: "relative",
  79. "padding-bottom": "56.25%"
  80. }).append(
  81. $("<iframe>", {
  82. src: "https://www.youtube.com/embed/" + videoId
  83. + "?autoplay=1" // Plays automatically
  84. + "&loop=1" // Loops the video
  85. + "&showinfo=0" // Hides video title
  86. + "&iv_load_policy=3" // Hides annotations
  87. + "&rel=0", // Hides relevant videos
  88. frameborder: 0,
  89. allowfullscreen: ""
  90. }).css({
  91. position: "absolute",
  92. top: 0,
  93. left: 0,
  94. width: "100%",
  95. height: "100%"
  96. })
  97. )
  98. );
  99. };
  100.  
  101. var heading = $("h1:first").text();
  102. if (heading) {
  103. var weapon = heading.substr(0, heading.indexOf(" Skins"));
  104. var resultBoxes = $(".result-box");
  105. $.searchVideos(weapon, resultBoxes.length + 10).success($.addVideoLinks);
  106. }
  107. });

QingJ © 2025

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