Steam Game Page - Add Links To Game Trailer & Gameplay Search On YouTube

This script adds links to the right of the breadcrumbs on a Steam game page so you can easily and quickly search youtube for a trailer for the game or for a gameplay video.

当前为 2017-11-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Steam Game Page - Add Links To Game Trailer & Gameplay Search On YouTube
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description This script adds links to the right of the breadcrumbs on a Steam game page so you can easily and quickly search youtube for a trailer for the game or for a gameplay video.
  6. // @author You
  7. // @match http://store.steampowered.com/app/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. const gameName = document.querySelector('.apphub_AppName').textContent.trim()
  12.  
  13. const breadcrumbsContainer = document.querySelector('.breadcrumbs')
  14.  
  15. breadcrumbsContainer.setAttribute('style', `
  16. display: flex;
  17. justify-content: space-between;
  18. margin-right: 320px;
  19. `)
  20.  
  21. const metaLinksContainer = document.createElement('div')
  22. metaLinksContainer.setAttribute('style', `
  23. display: flex;
  24. justify-content: space-between;
  25. width: 126px;
  26. `)
  27.  
  28. const ytTrailerSearchLink = document.createElement('a')
  29. ytTrailerSearchLink.href = 'https://www.youtube.com/results?search_query=' + encodeURIComponent(gameName) + ' trailer'
  30. ytTrailerSearchLink.textContent = 'Trailer'
  31. ytTrailerSearchLink.setAttribute('target', '_blank')
  32.  
  33. const ytGameplaySearchLink = document.createElement('a')
  34. ytGameplaySearchLink.href = 'https://www.youtube.com/results?search_query=' + encodeURIComponent(gameName) + ' gameplay'
  35. ytGameplaySearchLink.textContent = 'Gameplay'
  36. ytGameplaySearchLink.setAttribute('target', '_blank')
  37.  
  38. metaLinksContainer.appendChild(ytTrailerSearchLink)
  39. metaLinksContainer.appendChild(ytGameplaySearchLink)
  40.  
  41. breadcrumbsContainer.appendChild(metaLinksContainer)