Limit Twitter

use your time effectively and make the world better!

Fra og med 20.09.2019. Se den nyeste version.

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.

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

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

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

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

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

// ==UserScript==
// @name         Limit Twitter
// @namespace    https://twitter.com/seiun_kunisaki
// @version      1.0.2
// @description  use your time effectively and make the world better!
// @author       @seiun_kunisaki
// @match        https://twitter.com/*
// @match        https://mobile.twitter.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var remainSecond = 60;
    var baseStr = {'ja': '残り:%d 秒', 'zh': '剩下:%d 秒',
                   'id': '%d detik tersisa', 'pt': '%d segundos restantes',
                   'de': 'Noch: %d Sekunden', 'es': '%d segundos restantes',
                   'nl': '%d seconden resterend', 'fr': '%d secondes restantes',
                   'it': '%d secondi rimanenti', 'ko': '나머지:%d 초',
                   'en': 'remaining:%d s', 'default': 'remaining:%d s'};
    var redirectUrl = 'https://www.hellowork.go.jp/'; // Introducing your work site :)

    var htmlLang = document.documentElement.getAttribute('lang');
    if (!baseStr[htmlLang]) htmlLang = 'default';
    var originalStr = null;

    var countDown = function() {
      if (location.pathname !== '/home') return;

      if (remainSecond == 0) {
        document.location.href = redirectUrl;
      }
      var h2s = document.getElementsByTagName('h2');
      if (h2s && originalStr == null) {
        originalStr = h2s[1].innerHTML;
      }
      h2s[1].innerHTML = originalStr + " " + baseStr[htmlLang].replace('%d', remainSecond);
      remainSecond--;
    }
    setInterval(countDown, 1000);
})();