From ec36fd3c8e3eb009759cc25c225a6fa83b877bf9 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Mon, 28 Oct 2024 19:12:45 -0400 Subject: [PATCH] Warning for clicking an external link --- .../dynamix/include/DefaultPageLayout.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index ee4ab10ff..d8513f31a 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -1111,6 +1111,38 @@ $(function() { } $('form').append($('').attr({type:'hidden', name:'csrf_token', value:csrf_token})); }); + +$('body').on("click","a", function(e) { + href = $(this).attr("href").trim(); + target = $(this).attr("target"); + + if ( href ) { + if ( href.indexOf("/") == 0 ) { // all internal links start with "/" + return; + } + if ( href.match('https://[^\.]*.(my)?unraid.net/') || href.indexOf("https://unraid.net/") == 0 || href == "https://unraid.net" ) { + return; + } else { + if (href !== "#" && href.indexOf("javascript") !== 0) { + e.preventDefault(); + swal({ + title: "", + text: "

"+href, + html: true, + type: 'warning', + showCancelButton: true, + showConfirmButton: true, + cancelButtonText: "", + confirmButtonText: "" + },function(isConfirm) { + if (isConfirm) { + window.open(href,target); + } + }); + } + } + } +});