AI Studio Prompter

Maintains constant system instructions across new chats in Google's AI Studio.

// ==UserScript==
// @name         AI Studio Prompter
// @version      0.3
// @description  Maintains constant system instructions across new chats in Google's AI Studio.
// @author       MJE43
// @license      MIT
// @match        https://aistudio.google.com/prompts/*
// @grant        none
// @namespace https://gf.qytechs.cn/users/1499286
// ==/UserScript==

(function() {
    'use strict';

    // --- 1. 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 populateInstructions() {
        if (mainInterval) clearInterval(mainInterval);

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

            if (instructionTextArea && instructionTextArea.value === '') {
                console.log('Tampermonkey: Found empty System Instructions field. Populating now.');
                instructionTextArea.value = systemInstructions;

                // Fire input event to notify the app of the change
                const inputEvent = new Event('input', { bubbles: true });
                instructionTextArea.dispatchEvent(inputEvent);

                clearInterval(mainInterval);
                mainInterval = null;
            } else if (instructionTextArea && instructionTextArea.value !== '') {
                clearInterval(mainInterval);
                mainInterval = null;
            }
        }, 750);
    }

    // Detect navigation changes (e.g. New Chat)
    let lastUrl = location.href;
    new MutationObserver(() => {
        const url = location.href;
        if (url !== lastUrl) {
            lastUrl = url;
            setTimeout(populateInstructions, 500);
        }
    }).observe(document.body, { subtree: true, childList: true });

    setTimeout(populateInstructions, 1500);

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址