OmniFocus

Make sure websites always think you are focused on them

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          OmniFocus
// @namespace     https://greasyfork.org/en/users/198860-zyenith
// @author        zyenith
// @version       0.0.1
// @description   Make sure websites always think you are focused on them
// @match         *://*/*
// @run-at        document-start
// @grant         unsafeWindow
// @antifeature   Tracking, for compatibility info
// @require       https://greasyfork.org/scripts/410512-sci-js-from-ksw2-center/code/scijs%20(from%20ksw2-center).js
// ==/UserScript==

const { document } = unsafeWindow;

unsafeWindow.onblur = null;
unsafeWindow.blurred = false;

unsafeWindow.document.hasFocus = function() {
    return true;
};

unsafeWindow.document.onvisibilitychange = undefined;

const _arr = ["visibilitychange", "webkitvisibilitychange", "blur", "mozvisibilitychange", "msvisibilitychange"];
for (const eventName of _arr) {
    unsafeWindow.document.addEventListener(eventName, (event) => {
        event.stopImmediatePropagation();
    }, true);
}

Object.defineProperties(unsafeWindow.document, {
    hidden: {
        value: false
    },
    mozHidden: {
        value: false
    },
    msHidden: {
        value: false
    },
    webkitHidden: {
        value: false
    },
    visibilityState: {
        get() {
            return "visible";
        }
    }
});