Set AI Studio Content Filters to None With One Click

see name

当前为 2024-07-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @license it made me include this idk
  3. // @name Set AI Studio Content Filters to None With One Click
  4. // @description see name
  5. // @namespace http://tampermonkey.net/
  6. // @version 0.3
  7. // @match *://aistudio.google.com/*
  8. // @grant none
  9. // @author HORSELOCKSPACEPIRATE/rayzorium
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to set sliders to 0
  16. function setSlidersToZero() {
  17. const dialogContainer = document.querySelector('mat-dialog-container');
  18. if (dialogContainer) {
  19. const sliders = dialogContainer.querySelectorAll('mat-slider input[type="range"]');
  20. sliders.forEach(slider => {
  21. slider.value = -4;
  22. slider.dispatchEvent(new Event('input', { bubbles: true }));
  23. slider.dispatchEvent(new Event('change', { bubbles: true }));
  24. });
  25.  
  26. // Close the dialog box
  27. const closeButton = dialogContainer.querySelector('button[aria-label="Close Run Safety Settings"]');
  28. if (closeButton) {
  29. closeButton.click();
  30. }
  31. }
  32. }
  33.  
  34. // Mutation observer to detect when the safety settings dialog appears
  35. const observer = new MutationObserver((mutations) => {
  36. mutations.forEach((mutation) => {
  37. if (mutation.addedNodes.length) {
  38. const addedNode = mutation.addedNodes[0];
  39. if (addedNode.nodeType === Node.ELEMENT_NODE && addedNode.matches('mat-dialog-container')) {
  40. setTimeout(setSlidersToZero, 150); // Adding a slight delay to ensure sliders are loaded
  41. }
  42. }
  43. });
  44. });
  45.  
  46. // Start observing the body for additions of the dialog container
  47. observer.observe(document.body, { childList: true, subtree: true });
  48.  
  49. // Adding click event listener to the "Edit safety settings" button
  50. document.addEventListener('click', function(e) {
  51. if (e.target && (e.target.closest('.edit-safety-button') || e.target.closest('.settings-item.safety-settings'))) {
  52. // We wait for the dialog to be added to the DOM
  53. observer.observe(document.body, { childList: true, subtree: true });
  54. }
  55. });
  56. })();