pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
at main 49 lines 932 B view raw
1import { useEffect, useState } from "react"; 2 3export function useIsTV() { 4 const [isTV, setIsTV] = useState(false); 5 6 useEffect(() => { 7 function detectTV() { 8 const userAgent = navigator.userAgent || ""; 9 10 const tvKeywords = [ 11 "Silk", 12 "SmartTV", 13 "Tizen", 14 "Web0S", 15 "SamsungBrowser", 16 "HbbTV", 17 "Viera", 18 "NetCast", 19 "AppleTV", 20 "Android TV", 21 "GoogleTV", 22 "Roku", 23 "PlayStation", 24 "Xbox", 25 "Opera TV", 26 "AquosBrowser", 27 "Hisense", 28 "SonyBrowser", 29 "SharpBrowser", 30 "AFT", // Amazon Fire TV 31 "Chromecast", 32 ]; 33 34 const isTVDetected = tvKeywords.some((keyword) => 35 userAgent.toLowerCase().includes(keyword.toLowerCase()), 36 ); 37 38 if (isTVDetected) { 39 setIsTV(true); 40 } 41 } 42 43 detectTV(); 44 }, []); 45 46 return { 47 isTV, 48 }; 49}