Skip to content

Instantly share code, notes, and snippets.

@danielsgriffin
Created January 23, 2024 00:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielsgriffin/f1bfbcc2881cb5fab891d9e26d6867d8 to your computer and use it in GitHub Desktop.
Save danielsgriffin/f1bfbcc2881cb5fab891d9e26d6867d8 to your computer and use it in GitHub Desktop.
On ChatGPT, any mention of 'Doing research with Bing' on the page will click the Stop generating button.
// ==UserScript==
// @name DeBing
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Any mention of 'Doing research with Bing' on the page will click the Stop generating button.
// @author danielsgriffin
// @match https://chat.openai.com/*
// @grant GM_addStyle
// ==/UserScript==
(function () {
'use strict';
// User variables
// Remove the popup after X seconds
const seconds = .5;
// Testing (comment out the below for normal use)
// showDebingedPopup();
// CSS adapted from Ana Tudor at https://codepen.io/thebabydino/pen/nBNVbr
const customCSS = `
.debinging {
position: relative;
margin: 1em auto;
border: 25px solid red;
width: 16em; height: 16em;
border-radius: 50%;
box-shadow:
0 0 0 5px white,
0 0 15px 2px black;
background: linear-gradient(135deg, transparent 46%, red 46%, red 54%, transparent 54%),
linear-gradient(90deg, transparent 15%, transparent 15%, transparent 22.25%, transparent 12.25%, transparent 97.5%, transparent 97.5%) no-repeat 50% 50%;
background-size: 100% 100%, 65% 2em, 80% 2em;
}
`;
GM_addStyle(customCSS);
// Function to show a popup with Bing logo
function showDebingedPopup() {
const popupContainer = document.createElement('div');
popupContainer.style.cssText = `
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 100;
background-color: white;
width: 75vw;
height: 75vw;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); /* Smooth shadow */
animation: fadeIn 0.5s; /* Smooth fade-in effect */
`;
// Create a new div for the popup
const popup = document.createElement('div');
popup.classList.add('debinging');
popup.style.cssText = `
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 300;
background-color: none;
width: 50vw;
height: 50vw;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); /* Smooth shadow */
animation: fadeIn 0.5s; /* Smooth fade-in effect */
`;
// Create an img element for the Bing logo
const bingLogo = document.createElement('img');
bingLogo.src = 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/Bing_Fluent_Logo.svg/1024px-Bing_Fluent_Logo.svg.png';
// Set the Bing logo dimensions to maintain aspect ratio and fit within the popup
const aspectRatio = 1024 / 1547;
const maxWidth = parseFloat(popup.style.width) * 0.9; // 90% of the popup width to leave a margin
const maxHeight = parseFloat(popup.style.height) * 0.9; // 90% of the popup height to leave a margin
const isWindowWider = window.innerWidth / window.innerHeight > aspectRatio;
const calculatedWidth = isWindowWider ? maxHeight * aspectRatio : maxWidth;
const calculatedHeight = isWindowWider ? maxHeight : maxWidth / aspectRatio;
bingLogo.style.cssText = `
width: ${calculatedWidth*3}px;
height: ${calculatedHeight*3}px;
border-radius: 50%;
z-index: 200;
`;
// Append the image to the popup
popupContainer.appendChild(bingLogo);
// Create a div for the caption
const caption = document.createElement('div');
caption.style.cssText = `
position: absolute;
top: 2%;
width: 100%;
text-align: center;
font-size: 10vw;
font-weight: bold;
font-family: 'Helvetica Neue', sans-serif; /* Better font */
color: #333; /* Smoother font color */
`;
caption.textContent = 'Debinged!';
// Create a div for the small text
const smallText = document.createElement('div');
smallText.style.cssText = `
padding: 0;
margin: 0;
margin-left: 3px;
position: absolute;
bottom: 0;
width: 100%;
text-align: left;
font-size: 8px;
font-family: 'Arial', sans-serif; /* Better font */
color: #666; /* Smoother font color */
`;
smallText.textContent = 'Bing logo used without permission.';
// Append to the popupContainer
popupContainer.appendChild(smallText);
popupContainer.appendChild(caption);
popupContainer.appendChild(popup);
// Append the popup to the body
document.body.appendChild(popupContainer);
setTimeout(() => {
popupContainer.style.animation = 'fadeOut 0.5s'; /* Smooth fade-out effect */
setTimeout(() => document.body.removeChild(popupContainer), 500); // Wait for fade-out to finish
}, seconds * 1000); // Multiply by 1000 to convert seconds to milliseconds
}
// Create an observer instance to watch for DOM changes
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach((node) => {
// Check if the node or any of its children contain the text 'Doing research with Bing'
// MAYBE-LATER Adjust to only match in the expected context, not in standard text from the user or ChatGPT.
const nodeToCheck = node.textContent ? node : node.innerText.toLowerCase().includes('bing');
if (nodeToCheck && nodeToCheck.textContent.includes('Doing research with Bing')) {
// Find the button with aria-label 'Stop generating'
const stopButton = document.querySelector('button[aria-label="Stop generating"]');
if (stopButton) {
// Click the button
stopButton.click();
// Call the function to show the popup
showDebingedPopup();
console.log('Clicked "Stop generating" button.');
}
}
});
}
});
});
// Configuration for the observer
const config = { childList: true, subtree: true };
// Start observing the body for DOM mutations
observer.observe(document.body, config);
// MAYBE-LATER - include a popup with links to direct searches of the users query on search systems of the users choice
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment