Skip to content

Instantly share code, notes, and snippets.

@senseisimple
Last active January 4, 2023 18:01
Show Gist options
  • Select an option

  • Save senseisimple/00f4ca4646def7632bde8bf6d28df5c6 to your computer and use it in GitHub Desktop.

Select an option

Save senseisimple/00f4ca4646def7632bde8bf6d28df5c6 to your computer and use it in GitHub Desktop.
MS Teams status keeper - Angular js hook
// ==UserScript==
// @name Teams Presence Keeper - Angular
// @namespace Teams Presence Keeper - Angular
// @version 1.0
// @match *://*.teams.microsoft.com/*
// @exclude *://*.teams.microsoft.com/multi-window/*
// @noframes
// @run-at document-idle
// @inject-into auto
// @icon https://www.google.com/s2/favicons?sz=64&domain=microsoft.com
// @grant none
// @source https://gist.github.com/senseisimple/00f4ca4646def7632bde8bf6d28df5c6
// @downloadURL https://gist.github.com/senseisimple/00f4ca4646def7632bde8bf6d28df5c6/raw/e2f029ec167b0aa8a55f1d08e0eab035ccc0994c/teams_keep_status_ang.user.js
// ==/UserScript==
//CONFIGURATION:
/**
*
* Possible status choices are:
* 1 = Available
* 2 = Busy
* 3 = DoNotDisturb
* 4 = BeRightBack
* 5 = Away
* 6 = Offline
* Set your preferred status here:
*/
const desired_status = 1;
const update_interval = 45; //seconds
function put_status(status) {
let statii=[1,2,3,4,5,6]
if (! statii.includes(desired_status)) {
console.log("forceestatus: Invalid status string configured: "+desired_status);
return false;
}
if (angular.element(document.body).injector().get('presenceService').setMyStatus(desired_status, null, true)) {
console.log(`forcestatus ${desired_status} - OK`);
return true;
}
}
console.log("Started Teams forcestatus",desired_status,update_interval);
(function loop() {
'use strict';
setTimeout(() => {
put_status(desired_status);
loop();
}, update_interval * 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment