您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically follows the link to your local instance. If you go back in history, it will not re-redirect again.
// ==UserScript== // @name Automatic Redirect on My Home Assistant Links to Local Instance // @name:de Automatische Umleitung bei My Home Assistant-Links zur lokalen Instanz // @description Automatically follows the link to your local instance. If you go back in history, it will not re-redirect again. // @description:de Folgt automatisch dem Link zur lokalen Instanz. Beim Zurückgehen in der Historie, erfolgt keine erneute Weiterleitung. // @version 1.3.0 // @grant none // @match https://my.home-assistant.io/redirect/* // @exclude https://my.home-assistant.io/redirect/_change/* // @namespace https://github.com/SVNKoch // @author SVNKoch // @icon64URL https://my.home-assistant.io/images/favicon.png // @homepageURL https://github.com/SVNKoch/my-home-assistant-automatic-link-redirect-userscript // @supportURL https://github.com/SVNKoch/my-home-assistant-automatic-link-redirect-userscript/issues // @license MIT // ==/UserScript== waitForLinkElementToLoad(function() { if (!isBackNavigation()) { redirectToHomeAssistantInstance(); } }); function waitForLinkElementToLoad(callback) { const targetElement = document.querySelector('a.open-link'); if (targetElement) { callback(targetElement); } else { const observer = new MutationObserver(function(mutationsList, observer) { const targetElement = document.querySelector('a.open-link'); if (targetElement) { observer.disconnect(); callback(targetElement); } }); observer.observe(document.body, { childList: true, subtree: true }); } } function redirectToHomeAssistantInstance() { const openLink = document.querySelector('a.open-link'); if (openLink) { window.location.href = openLink.href; } } function isBackNavigation() { const navigationEntries = window.performance.getEntriesByType('navigation'); if (navigationEntries.length > 0) { const navType = navigationEntries[0].type; return navType === 'back_forward'; } return false; }