Twitter Widget Fixer for TT1069

Fix Twitter widgets on TT1069 which are not working

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        Twitter Widget Fixer for TT1069
// @namespace   https://greasyfork.org/users/790126-erohmst
// @version     0.1.1
// @description Fix Twitter widgets on TT1069 which are not working
// @author      erohmst
// @match       *://www.tt1069.com/bbs/thread-*
// @match       *://www.tt1069.com/bbs/forum.php*
// @grant       none
// ==/UserScript==

(function() {
  'use strict';
  const widgetScript = document.createElement('script');
  widgetScript.src = 'https://platform.twitter.com/widgets.js';
  widgetScript.async = true;
  widgetScript.charset = 'utf-8';
  document.head.append(widgetScript);
  
  const embeds = document.querySelectorAll('iframe[src^="https://twitter.com/i/videos/tweet/"]');
  for(const emb of embeds) {
    const tweetId = emb.src.replace('https://twitter.com/i/videos/tweet/', '');
    emb.insertAdjacentHTML('beforebegin', '<blockquote class="twitter-tweet"><a href="https://twitter.com/i/status/'
                           + tweetId + '?ref_src=twsrc%5Etfw"></a></blockquote>');
    emb.remove();
  }
})();