Created
October 12, 2014 15:38
-
-
Save twinkfrag/26793a62c64205441338 to your computer and use it in GitHub Desktop.
twitterの画像付きステータスページにtumblrへの投稿リンクを配置するUserScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name add twitter tumblr photo post | |
// @namespace twinkfrag.net | |
// @include /https?://twitter\.com/\w+/status/\d+/ | |
// @include /https?://twitter\.com/\w+/status/\d+/photo/1/ | |
// @desctiption twitterの画像付きステータスページにtumblrへの投稿リンクを配置します | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js | |
// @version 1.00 | |
// @grant none | |
// ==/UserScript== | |
$(function() { | |
var $tweettext = $(".permalink-tweet .tweet-text").clone().removeAttr("class data-aria-label-part lang"); | |
$tweettext.find("a").removeAttr("class dir data-pre-embedded"); | |
var time = $("span.metadata span").html(); | |
var name = $(".permalink-tweet [data-name]").attr("data-name"); | |
var screenname = $(".permalink-tweet [data-screen-name]").attr("data-screen-name"); | |
var imageURL = $("[data-url]").attr("data-url").replace(/https?:/,"").match(/[^:]+/)[0]+":orig"; | |
var embed = | |
$("<blockquote/>").addClass("twitter-tweet").append($tweettext.get(0).outerHTML).append( | |
"— "+name+" (@"+screenname+") ").append( | |
$("<a/>").attr("href", document.URL).append(time)) | |
.get(0).outerHTML + | |
$("<script async/>").attr("src", "//platform.twitter.com/widgets.js").attr("charset", "utf-8").get(0).outerHTML | |
$(".tweet-actions").append( | |
$("<li/>").addClass("action-share-tumblr-container").append( | |
$("<a/>").addClass("with-icn js-action-tumblr-share-photo").attr("href", "#").append( | |
$("<span/>").addClass("Icon Icon--share")).append( | |
$("<b/>").append("Share on tumblr")))); | |
$(".js-action-tumblr-share-photo").click(function(){ | |
window.open("https://www.tumblr.com/share/photo?source=" + encodeURIComponent(imageURL) + | |
"&caption=" + encodeURIComponent(embed) + | |
"&click_thru=\"\"" | |
)}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment