Open Tweet Image

A thrown together script to open a tweets image in a new tab.

当前为 2014-11-15 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Open Tweet Image
// @author      Arctosmous
// @namespace   https://www.googledrive.com/host/0B0T32ON-a3StUWZGUW9TbFZCVHM/
// @description A thrown together script to open a tweets image in a new tab.
// @include     https://twitter.com/*
// @exclude     https://twitter.com/settings/*
// @grant       none
// @version     1.0.1
// ==/UserScript==

OpenTweetImage = {
    getImageURL: function()
    {
        return $(".Gallery-content > .Gallery-media > .media-image").attr("src");
    },
    
    createButton: function()
    {
        $(".Gallery-content").prepend('<a id="OpenTweetImage" class="modal-btn" role="button" title="Open image in new tab" style="position: absolute; right: -30px; padding: 0; height: auto; top: 40px; color: white;"><span class="Icon Icon--photo Icon--large"><span class="visuallyhidden">Open image in new tab</span></span></a>');
    },
    
    buttonClickHandler: function()
    {
        $("body").on("click", "#OpenTweetImage", function () {
            window.open(OpenTweetImage.getImageURL(), "_blank");
        });
    }
}

window.addEventListener("load", function() {
    // script injection
    OpenTweetImage.createButton();
    OpenTweetImage.buttonClickHandler();
}, false);