InoReader - Twitter/IG Widgets

Turn twitter and instragram blockquotes in posts into widgets.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         InoReader - Twitter/IG Widgets
// @version      1.0.2
// @description  Turn twitter and instragram blockquotes in posts into widgets.
// @grant        unsafeWindow
// @include      http*://*.inoreader.com/*
// @require      https://greasyfork.org/scripts/31694-ondom/code/OnDom.js
// @namespace    https://greasyfork.org/users/316912
// ==/UserScript==

(function(){

  'use strict';
  
  onDom('.article_content', replaceTwitter);

  function replaceTwitter(element) {

    let $ = unsafeWindow.jQuery;
    let $this = $(element);
    
    let tweets = $this.find('blockquote a[href*="twitter.com"]').closest("blockquote");
    
    if( tweets.length !== 0 ) {
      tweets.addClass("twitter-tweet");
      $.getScript("https://platform.twitter.com/widgets.js");
    }
    
    let grams = $this.find('blockquote a[href*="instagram.com"]').closest("blockquote");
    
    if( grams.length !== 0 ) {
      grams.addClass("instagram-media");
      $.getScript("https://www.instagram.com/embed.js");
    }    
  }

})();