SuperRoach

Gamestah automation helper

  1. // ==UserScript==
  2. // @name SuperRoach
  3. // @namespace http://www.gamestah.com
  4. // @description Gamestah automation helper
  5. // @include http://www.gamestah.com/wp-admin/post-new.php
  6. // @include https://www.gamestah.com/wp-admin/post-new.php
  7. // @author Brett James
  8. // @version 1
  9. // @grant none
  10. // ==/UserScript==
  11. //this.$ = this.jQuery = jQuery.noConflict(true);
  12.  
  13. var datathing
  14. $(document).ready(function ()
  15. {
  16.  
  17. var youtube_HTTP = prompt('Paste your youtube website');
  18. //var youtube_HTTP = 'https://www.youtube.com/watch?v=3FY2_EP7-F0';
  19. var youtube_ID;
  20.  
  21. function youtube_parser(url) {
  22. var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
  23. var match = url.match(regExp);
  24. if (match && match[2].length == 11) {
  25. return match[2];
  26. }
  27. }
  28. if (youtube_HTTP != null) {
  29. youtube_ID = youtube_parser(youtube_HTTP);
  30. }
  31. $.getJSON("https://www.googleapis.com/youtube/v3/videos?part=snippet&id="+ youtube_ID +"&key=AIzaSyA7YJ4FDhYGZ-EYyt0LPegi_AI3YYNs3Ew", function (data) {
  32. //Prepare data
  33. var youtube_thumbnail = data.items[0].snippet.thumbnails.maxres.url;
  34. var youtube_title = data.items[0].snippet.title;
  35. var youtube_description = data.items[0].snippet.description;
  36. var youtube_publishdate = data.items[0].snippet.publishedAt;
  37. var youtube_tags = data.items[0].snippet.tags.toString()
  38. // Check to see what game it is.
  39. var rocket_league_regexp = new RegExp(/Rocket league| RL /i)
  40. var rocket_league = rocket_league_regexp.test(youtube_title)
  41. var results = $("<div id=\"yt_results\" style=\" border-radius: 5px; display: block; padding: 0px 0px 2px 5px; margin: 5px; background: rgb(221, 153, 51) none repeat scroll 0% 0%; border: 3px solid rgb(149, 191, 58); \"><h4>Youtube video found: " + youtube_title + "</h4><p>This is the highres thumbnail. <a href=\""+ youtube_thumbnail +"\"><img src=\"" + youtube_thumbnail + "\" width=120 width=90> Save and use it! </a></p><p>To finish up, please set this image as the featured image (bottom right), and type in the casters names one at a time in the Cactus Channel below</p></div>");
  42. $('#poststuff').prepend(results);
  43. $('#yt_results').hide().show('slow');
  44. $('#tm_video_url-cmb-field-0').val(youtube_HTTP); // youtube url
  45. // Set the Page Title
  46. $('#title').val(youtube_title);
  47. // Set the Description
  48. $("#content-html").click();
  49. $("#content").val(youtube_description);
  50. $("#content-tmce").click() // Go back to visual when done
  51. // Click the button to make the post be a video
  52. $("#post-format-video").click()
  53. if (rocket_league)
  54. {
  55. $("#in-popular-category-287").click();
  56. $("#new-tag-post_tag").val(youtube_tags)
  57. // Add the tags
  58. $("input.button.tagadd").click();
  59. }
  60.  
  61. });
  62. });