Limit Twitter

Use your time effectively and make the world better!

当前为 2019-09-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         Limit Twitter
// @namespace    https://twitter.com/seiun_kunisaki
// @version      1.1.0
// @description  Use your time effectively and make the world better!
// @author       @seiun_kunisaki
// @match        https://twitter.com/*
// @match        https://mobile.twitter.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  // TODO: Android Firefox don't call event certainly.
  window.addEventListener('DOMContentLoaded', function(){

    /* == User Setting Start == */
    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 forceSPmode = false; // apply SmartPhone mode to PC browser. true or false

   /*  == User Setting End == */

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

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

      if (remainSecond === 0) document.location.href = redirectUrl;

      // PC mode
      if ((location.host === 'twitter.com' || window.innerWidth >= 500) && !forceSPmode) {
        var h2s = document.getElementsByTagName('h2');
        if (h2s && originalStr === null) {
          originalStr = h2s[1].innerHTML;
        }
        h2s[1].innerHTML = originalStr + " " +
            baseStr[htmlLang].replace('%d', remainSecond);
      } else {
      // SmartPhone mode
        if (divElement) {
          divElement.parentNode.removeChild(divElement); // remove self
        }
        (function() {
          divElement = document.createElement('div');
          divElement.style.width = '70%';
          divElement.style.height = '50px';
          divElement.style.position = 'fixed';
          divElement.style.bottom = '13px';
          divElement.style.left = '13px';
          divElement.style.margin = '0 auto';
          divElement.style.border = 'solid 5px black';
          divElement.style.background = '#FFFFFF';
          divElement.style.overflow = 'hidden';
          divElement.style.zIndex = 10;
          divElement.style.fontSize = '30px';
          divElement.style.textAlign = 'center';
          divElement.style.verticalAlign = 'center';
          document.body.appendChild(divElement);
        })();
        divElement.innerHTML = baseStr[htmlLang].replace('%d', remainSecond);
      }
      remainSecond--;
    };

    setInterval(countDown, 1000);

  }, false);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址