SuperRoach

Gamestah automation helper

当前为 2016-03-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        SuperRoach
// @namespace   http://www.gamestah.com
// @description Gamestah automation helper
// @include     http://www.gamestah.com/wp-admin/post-new.php
// @include     https://www.gamestah.com/wp-admin/post-new.php
// @author      Brett James
// @version     1
// @grant       none
// ==/UserScript==
//this.$ = this.jQuery = jQuery.noConflict(true);

var datathing
$(document).ready(function ()
{
  
  

  var youtube_HTTP = prompt('Paste your youtube website');
  //var youtube_HTTP = 'https://www.youtube.com/watch?v=3FY2_EP7-F0';
  var youtube_ID;

  function youtube_parser(url) {
    var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
    var match = url.match(regExp);
    if (match && match[2].length == 11) {
      return match[2];
    }
  }
  if (youtube_HTTP != null) {
    youtube_ID = youtube_parser(youtube_HTTP);
  }
  
 
  
  $.getJSON("https://www.googleapis.com/youtube/v3/videos?part=snippet&id="+ youtube_ID +"&key=AIzaSyA7YJ4FDhYGZ-EYyt0LPegi_AI3YYNs3Ew", function (data) {
    
    //Prepare data 
    var youtube_thumbnail = data.items[0].snippet.thumbnails.maxres.url;
    var youtube_title = data.items[0].snippet.title;
    var youtube_description = data.items[0].snippet.description;
    var youtube_publishdate = data.items[0].snippet.publishedAt;
    var youtube_tags = data.items[0].snippet.tags.toString()
    
    // Check to see what game it is.
    var rocket_league_regexp = new RegExp(/Rocket league| RL /i)
    var rocket_league = rocket_league_regexp.test(youtube_title)    
    
    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>");
    $('#poststuff').prepend(results);
    $('#yt_results').hide().show('slow');
    $('#tm_video_url-cmb-field-0').val(youtube_HTTP); // youtube url
    
    // Set the Page Title
    $('#title').val(youtube_title);
    
    // Set the Description
    $("#content-html").click();
    $("#content").val(youtube_description); 
    $("#content-tmce").click() // Go back to visual when done
    // Click the button to make the post be a video
    $("#post-format-video").click()
    
    if (rocket_league) 
      {
        $("#in-popular-category-287").click();
        $("#new-tag-post_tag").val(youtube_tags) 
        // Add the tags
        $("input.button.tagadd").click();
        
      }

    
  });
});