You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
index.ts 是在我想出這個邪門歪道之後請 AI 生成的,因為我不會寫 Type script,其餘包含 json 都是我親自寫的。
程式
plugin.json
{
"id": "voyager.AI-studio-paste-youtube-link",
"name": "AI studio · Paste youtube link",
"version": "1.0.0",
"description": "AI studio turn all youtube link into media,and delete all text behind that line as well, but not one wants that, this plugin stop that from happening",
"i18n": {
"author": "hyaoang",
"matches": ["https://aistudio.google.com/*"]
}
}
index.ts
exportfunctioninitAIStudioYouTubePaste(){if(!window.location.hostname.includes('aistudio.google.com')){return;}constYT_URL_REGEX=/(https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/)([^\s]+)/gi;document.addEventListener('paste',(event: ClipboardEvent)=>{constclipboardData=event.clipboardData;if(!clipboardData)return;consttext=clipboardData.getData('text/plain');if(!text||!/(?:youtube\.com|youtu\.be)\//i.test(text)){return;}event.preventDefault();event.stopImmediatePropagation();letlastIndex=0;letmatch: RegExpExecArray|null;YT_URL_REGEX.lastIndex=0;while((match=YT_URL_REGEX.exec(text))!==null){constprecedingText=text.substring(lastIndex,match.index);if(precedingText){document.execCommand('insertText',false,precedingText);}constprefix=match[1];constsuffix=match[2];document.execCommand('insertText',false,prefix);document.execCommand('insertText',false,suffix);lastIndex=match.index+match[0].length;}constremainingText=text.substring(lastIndex);if(remainingText){document.execCommand('insertText',false,remainingText);}},true);console.log('[Voyager] AI Studio YouTube Paste Feature Loaded');}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
解決的問題
這個插件解決的問題是 AI studio 在貼上 YouTube 影片連結的時候會自動的將其轉換為影片媒體,導致連結消失。
解法
我把連結分成兩個部分貼上
https://www.youtube.com/watch?v=dQw4w9WgXcQ分別貼上都不會觸發轉換成多媒體可能的問題:如果有非常多個連結可能貼上速度慢一點點,但若連結不多沒有感覺
我不確定 PR 要怎麼寫,所以用 issue 的形式
演示
demo.mp4
理論上這個功能應該在選單部分做開關但我確定選單的結構要怎麼做
聲明
index.ts 是在我想出這個邪門歪道之後請 AI 生成的,因為我不會寫 Type script,其餘包含 json 都是我親自寫的。
程式
plugin.json
{ "id": "voyager.AI-studio-paste-youtube-link", "name": "AI studio · Paste youtube link", "version": "1.0.0", "description": "AI studio turn all youtube link into media,and delete all text behind that line as well, but not one wants that, this plugin stop that from happening", "i18n": { "author": "hyaoang", "matches": ["https://aistudio.google.com/*"] } }index.ts
All reactions