Teams - Always Online

Keeps you online between the hours specified in the script

目前為 2024-04-05 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Teams - Always Online
// @description Keeps you online between the hours specified in the script
// @namespace   Violentmonkey Scripts
// @match       *://*.teams.microsoft.com/_*
// @grant       none
// @version     1.01
// @author      -
// @description 3/6/2023, 11:35:30 AM
// @run-at       document-idle
// @license AGPL
// ==/UserScript==

var startTime =  9 * 60 + 0; // Work starts at 9am
var endTime   = 17 * 60 + 0; // Work ends at 5pm

function inTime() {
    var now = new Date();
    var time = now.getHours() * 60 + now.getMinutes();
    return time >= startTime && time < endTime;
}

(function(sendParam) {
  XMLHttpRequest.prototype.send = function() {
      if (typeof arguments[0] === 'string' || arguments[0] instanceof String) {
        try {
            let jsonMsg = JSON.parse(arguments[0]);
            if (jsonMsg.isActive != null) {
              if (jsonMsg.isActive === false) {
                if(inTime()) {
                  jsonMsg.isActive = true;
                  arguments[0] = JSON.stringify(jsonMsg);
                }
              }
            }
        } catch (e) {
          console.error('Teams - Always Online', e);
        }
      }

      sendParam.apply(this, arguments);
  };
})(XMLHttpRequest.prototype.send);