🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/05 05:01:36
🔄 下次更新时间:2026/01/05 06:01:36
手动刷新缓存

AI Studio Prompter

Automatically enforces system instructions across new chats in Google's AI Studio, then closes the panel.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         AI Studio Prompter
// @version      0.5
// @description  Automatically enforces system instructions across new chats in Google's AI Studio, then closes the panel.
// @author       MJE43
// @license      MIT
// @match        https://aistudio.google.com/prompts/*
// @grant        none
// @namespace https://greasyfork.org/users/1499286
// ==/UserScript==

(function () {
    'use strict';

    // --- EDIT YOUR SYSTEM INSTRUCTIONS HERE ---
    const systemInstructions = `
You are a hyper-intelligent, direct, and logical AI. Your primary function is to provide accurate, unbiased, and concise information. You operate with a high degree of intellectual honesty.

**Core Directives:**
1.  **Be Direct:** Address the user's query head-on. Omit apologies, disclaimers, and moralizing lectures. Assume the user is an expert who requires a direct answer.
2.  **Be Concise:** Use clear, precise language. Eliminate fluff and redundant phrases.
3.  **Format Logically:** Use markdown (headings, lists, bolding, code blocks) to structure responses for maximum clarity and readability.
4.  **Reason First:** For complex or multi-step queries, think step-by-step before providing the final answer.
5.  **State Ignorance:** If you do not know the answer or a query is beyond your capabilities, state it directly rather than hallucinating a response.
    `.trim();
    // -------------------------------------------

    let mainInterval = null;

    function runScript() {
        if (mainInterval) clearInterval(mainInterval);

        mainInterval = setInterval(() => {
            const instructionTextArea = document.querySelector('textarea[aria-label="System instructions"]');

            if (instructionTextArea) {
                // --- Textarea is VISIBLE ---
                if (instructionTextArea.value === '') {
                    console.log('AI Studio Prompter: Found empty System Instructions. Populating.');
                    instructionTextArea.value = systemInstructions;
                    const inputEvent = new Event('input', { bubbles: true });
                    instructionTextArea.dispatchEvent(inputEvent);

                    // --- AUTO-CLOSE THE PANEL ---
                    setTimeout(() => {
                        const toggleButton = document.querySelector('button[aria-label="System instructions"]');
                        if (toggleButton) {
                            console.log('AI Studio Prompter: Populated. Closing panel.');
                            toggleButton.click();
                        }
                    }, 250);

                } else {
                    console.log('AI Studio Prompter: System instructions already populated. Closing panel.');
                    const toggleButton = document.querySelector('button[aria-label="System instructions"]');
                    if (toggleButton) {
                        toggleButton.click();
                    }
                }

                clearInterval(mainInterval);
                mainInterval = null;

            } else {
                // --- Textarea is NOT VISIBLE ---
                const revealButton = document.querySelector('button[aria-label="System instructions"]');
                if (revealButton) {
                    console.log('AI Studio Prompter: Found "System instructions" button. Clicking to reveal.');
                    revealButton.click();
                } else {
                    console.log('AI Studio Prompter: Waiting for "System instructions" button to appear...');
                }
            }
        }, 750);
    }

    // --- Detect navigation changes ---
    let lastUrl = location.href;
    new MutationObserver(() => {
        const url = location.href;
        if (url !== lastUrl) {
            lastUrl = url;
            console.log('AI Studio Prompter: URL changed, re-running script.');
            setTimeout(runScript, 500);
        }
    }).observe(document.body, { subtree: true, childList: true });

    // --- Initial run ---
    console.log('AI Studio Prompter: Script loaded, starting initial run.');
    setTimeout(runScript, 1500);
})();