Greasy Fork is available in English.

保持屏幕常亮:唤醒锁定

根据Android内核自带的唤醒锁定功能来保持屏幕常亮

// ==UserScript==
// @name         保持屏幕常亮:唤醒锁定
// @namespace    https://viayoo.com/
// @version      0.1
// @description  根据Android内核自带的唤醒锁定功能来保持屏幕常亮
// @author       You
// @run-at       document-start
// @match        https://*/*
// @grant        GM_registerMenuCommand
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // create a reference for the wake lock
let wakeLock = null;

// create an async function to request a wake lock
const requestWakeLock = async () => {
  try {
    wakeLock = await navigator.wakeLock.request("screen");

//alert("唤醒锁定成功");
//setTimeout(() => alert("测试成功,每分钟尝试"), 60000);

    // listen for our release event
    wakeLock.addEventListener("release", () => {
      // if wake lock is released alter the UI accordingly
      alert("手动关闭了唤醒锁定");
    });
  } catch (err) {
    // if wake lock request fails - usually system related, such as battery
    alert("系统移除了唤醒锁定");
  }
};

GM_registerMenuCommand("开启唤醒锁定", () => {
  requestWakeLock();
});
GM_registerMenuCommand("关闭唤醒锁定", () => {
  wakeLock.release().then(() => {
    wakeLock = null;
  });
});


})();