Skip to content

Instantly share code, notes, and snippets.

View thangman22's full-sized avatar

Warat Wongmaneekit thangman22

View GitHub Profile
import {
FilesetResolver,
LlmInference,
} from "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-genai";
const genai = await FilesetResolver.forGenAiTasks(
"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-genai@latest/wasm"
);
llmInference = await LlmInference.createFromOptions(genai, {
if (HTMLScriptElement.supports && HTMLScriptElement.supports('speculationrules')) {
console.log('Your browser supports the Speculation Rules API.');
}
if (HTMLScriptElement.supports?.('speculationrules')) {
const specScript = document.createElement('script');
specScript.type = 'speculationrules';
const specRules = {
prerender: [
{
urls: ['/next.html'],
},
],
};
<script type="speculationrules">
{
"prerender": [
{
"source": "list",
"urls": ["next.html", "next2.html"],
"eagerness": "moderate"
},
{
"where": {
@media all and (display-mode: picture-in-picture) {
......
}
pipWindow.addEventListener("pagehide", (event) => {
const chatScreen Container = document.querySelector("#chat-screen-container");
const pipChatScreen = event.target.querySelector("#chat-screen");
playerContainer.append(pipPlayer);
});
pipButton.addEventListener("click", async () => {
const chatScreen = document.querySelector("#chat-screen");
// Open a Picture-in-Picture window.
const pipWindow = await documentPictureInPicture.requestWindow();
// Copy style sheets over from the initial document
// so that the player looks the same.
[...document.styleSheets].forEach((styleSheet) => {
try {
pipButton.addEventListener('click', async () => {
const chatScreen = document.querySelector("#chat-screen");
// Open a Picture-in-Picture window.
const pipWindow = await documentPictureInPicture.requestWindow();
// Move the player to the Picture-in-Picture window.
pipWindow.document.body.append(chatScreen);
});
<button popovertarget="my-popover" class="trigger-btn"> Open Popover </button>
<div id="my-popover" popover=manual>
<p>I am a popover with more information. Hit the close button or toggle to close me.<p>
<button class="close-btn" popovertarget="my-popover" popovertargetaction="hide">
<span aria-hidden="true">❌</span>
<span class="sr-only">Close</span>
</button>
</div>
<button popovertarget="my-popover"> Open Popover </button>
<div id="my-popover" popover>
<p>I am a popover with more information. Hit <kbd>esc</kbd> or click away to close me.<p>
</div>