Extract Images for Twitter

Adds a button that opens all attached images in a tweet as original size in new tabs.

目前為 2016-01-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Extract Images for Twitter
// @name:ja     Extract Images for Twitter
// @namespace   https://greasyfork.org/ja/users/24052-granony
// @description Adds a button that opens all attached images in a tweet as original size in new tabs.
// @description:ja ツィートに添付されているすべての画像をオリジナルのサイズで新しいタブに開くためのボタンを追加します.
// @include     https://twitter.com/*/status/*
// @author      granony
// @version     1.0.2
// @grant       none
// @license     MIT License
// ==/UserScript==
(function () {
  var contents = [
  ];
  var metas = document.getElementsByTagName('meta');
  for (var i = 0; i < metas.length; i++) {
    if (metas[i].getAttribute('property') == 'og:image') {
      var content = metas[i].getAttribute('content');
      content = content.replace(/:large$/, ':orig');
      contents.push(content);
    }
  }
  var onClick = function () {
    if (contents.length === 0) {
      return;
    }
    for (var i = 0; i < contents.length; i++) {
        var content = contents[i];
        window.open(content);
    }

  }
  var ga = document.getElementById('global-actions');
  if (!ga) {
    return;
  }
  var button = document.createElement('li');
  button.innerHTML = '<a style="cursor:pointer;" role="button" data-placement="bottom">'
  + '<span class="Icon Icon--photo dm Icon--large"></span>'
  + '<span class="text">Extract Images</span>'
  + '</a>';
  button.addEventListener('click', onClick);
  ga.appendChild(button);
}) ();