Auto Confirm New Chat for Gemini

Google Geminiで「新しいチャットを作成」ダイアログを自動で確認し、通知を表示します。

  1. // ==UserScript==
  2. // @name Auto Confirm New Chat for Gemini
  3. // @namespace https://qestir.hatenablog.com/
  4. // @version 1.1
  5. // @description Google Geminiで「新しいチャットを作成」ダイアログを自動で確認し、通知を表示します。
  6. // @match https://gemini.google.com/*
  7. // @grant none
  8. // @license GPL-3.0-or-later
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // 通知を表示する関数
  15. function showNotification(message, success = true) {
  16. const notification = document.createElement('div');
  17. notification.style.position = 'fixed';
  18. notification.style.bottom = '20px';
  19. notification.style.right = '20px';
  20. notification.style.padding = '10px 20px';
  21. notification.style.backgroundColor = success ? 'green' : 'red';
  22. notification.style.color = 'white';
  23. notification.style.fontSize = '14px';
  24. notification.style.borderRadius = '5px';
  25. notification.style.zIndex = '1000';
  26. notification.textContent = message;
  27. document.body.appendChild(notification);
  28. setTimeout(() => {
  29. notification.remove();
  30. }, 5000); // 5秒後に自動で消える
  31. }
  32.  
  33. // ポップアップ内の「チャットを新規作成」ボタンを探しクリックする関数
  34. function clickConfirmButton() {
  35. try {
  36. const confirmButton = document.querySelector('button[data-test-id="confirm-button"]');
  37. if (confirmButton) {
  38. confirmButton.click();
  39. showNotification('自動クリックに成功しました');
  40. return true; // ボタンがクリックされたらtrueを返す
  41. }
  42. } catch (error) {
  43. console.error('エラーが発生しました:', error);
  44. showNotification('自動クリックに失敗しました。詳細はコンソールを確認してください。', false);
  45. }
  46. return false; // ボタンが見つからないかエラーが発生した場合はfalseを返す
  47. }
  48.  
  49. // ページの読み込み完了時にボタンの存在をチェック
  50. window.addEventListener('load', () => {
  51. clickConfirmButton();
  52. });
  53.  
  54. // 一定間隔でボタンをチェック
  55. setInterval(() => {
  56. clickConfirmButton();
  57. }, 1000); // 1秒ごとにチェック
  58.  
  59. })();

QingJ © 2025

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