Twitter Instagram Cards - Photo Viewer

Now that Instagram have pulled their twitter support, this script adds back inline instagram photos.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Twitter Instagram Cards - Photo Viewer
// @namespace    http://chrisbradbury.net
// @author       Chris Bradbury
// @version      1.1
// @description  Now that Instagram have pulled their twitter support, this script adds back inline instagram photos.
// @include      https://twitter.com/*
// @require      http://code.jquery.com/jquery-latest.js
// @grant        none
// ==/UserScript==

$documentHeight = '';

function height(){
    
    if($documentHeight != document.body.scrollHeight){
       loadInstagram();
    }
    setTimeout(function(){ height(); },3000);
    
}

function loadInstagram(){
    $documentHeight = document.body.scrollHeight;
    $('body').find('.js-tweet-text').each(function(key,value){
        if ( value.innerHTML.indexOf("instagr.am") >= 0 ){
            if( value.innerHTML.indexOf('div class="instagram"') >= 0 ){ }else{
                $instagram = value.innerHTML.split('http://instagr.am/p/');
                $instagram = $instagram[1].split('/"');
                $instagram = $instagram[0];
                $(this).append('<div class="instagram" style="margin-top: 10px; margin-bottom: 5px;"><img width="435" src="http://instagr.am/p/'+$instagram+'/media" /></div>');
            }
        }else if( value.innerHTML.indexOf("instagram.com/p/") >= 0 ){
            if( value.innerHTML.indexOf('div class="instagram"') >= 0 ){ }else{
                $instagram = value.innerHTML.split('instagram.com/p/');
                $instagram = $instagram[1].split('/"');
                $instagram = $instagram[0];
                $(this).append('<div class="instagram" style="margin-top: 10px; margin-bottom: 5px;"><img width="435" src="http://instagr.am/p/'+$instagram+'/media" /></div>');
            }
        }
    });
}
$(document).ready(function(){
    loadInstagram(); 
    height();
});