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.0.1
// @description  use your time effectively and make the world better!
// @author       @seiun_kunisaki
// @match        https://twitter.com/*
// @match        https://mobile.twitter.com/*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/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 todayObj = new Date();
    var today = todayObj.getFullYear() + "/" + (todayObj.getMonth() + 1) + "/" + todayObj.getDate();
    if(!GM_getValue(today)) GM_setValue(today, '1');

    var countDown = function() {
      if (location.pathname === '/null') {
        var todayGMCount = GM_getValue(today);
        if (!todayGMCount) todayGMCount = 0
        alert(today + ' a total of ' + todayGMCount + ' second!');
        document.location.href = '/home';
      }
      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);
      GM_setValue(today, GM_getValue(today) - 0 + 1);
      remainSecond--;
    }
    setInterval(countDown, 1000);
})();

QingJ © 2025

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