1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// ==UserScript==
// @name Improved ChatGPT Text Definition
// @namespace http://tampermonkey.net/
// @version 0.8
// @description Define highlighted text using ChatGPT with improved streaming and state management
// @match https://forums.spacebattles.com/*
// @match https://forums.sufficientvelocity.com/*
// @match https://questionablequesting.com/*
// @match https://forum.questionablequesting.com/*
// @grant none
// ==/UserScript==
(function() {
"use strict";
const createStyleElement = () => {
console.log("Creating new style element");
const style = document.createElement("style");
style.id = "dynamic-styles";
style.textContent = `
/* Remove left gray area */
.p-body-inner {
padding-left: 10px !important;
margin-left: 0 !important;
}
/* Double the right gray area */
.p-body-inner {
padding-right: calc(var(--columnPadding) * 4) !important;
}
/* Shift the content to the left */
.p-body-inner {
transform: translateX(calc(var(--columnPadding) * -1));
}
/* Adjust the main content width */
.p-body-main {
max-width: calc(100% - var(--columnPadding) * 4) !important;
}
`;
console.log("New style element created:", style);
return style;
};
const getOrCreateStyleElement = () => {
console.log("Attempting to get or create style element");
let style = document.getElementById("dynamic-styles");
if (!style) {
console.log("Style element not found, creating new one");
style = createStyleElement();
document.head.appendChild(style);
console.log("New style element appended to head");
} else {
console.log("Existing style element found:", style);
}
return style;
};
const isWidthLessThan1918 = () => {
const width = window.innerWidth;
console.log("Current window width:", width);
const isLess = width < 1918;
console.log("Is width less than 1918?", isLess);
return isLess;
};
const toggleStylesBasedOnWidth = () => {
console.log("Toggling styles based on width");
const style = getOrCreateStyleElement();
const shouldEnable = isWidthLessThan1918();
style.disabled = !shouldEnable;
console.log("Style element disabled?", style.disabled);
};
// Run the function when the page loads
window.addEventListener("load", () => {
console.log("Page loaded, running toggleStylesBasedOnWidth");
toggleStylesBasedOnWidth();
});
// Also run the function when the window is resized
window.addEventListener("resize", () => {
console.log("Window resized, running toggleStylesBasedOnWidth");
toggleStylesBasedOnWidth();
});
// Immediate invocation to check if it runs on script load
console.log("Script loaded, running toggleStylesBasedOnWidth immediately");
toggleStylesBasedOnWidth();
const calculateAvailableSpace = () => {
const contentElement = document.querySelector(".p-body-inner");
if (!contentElement) return { width: window.innerWidth, height: window.innerHeight };
const contentRect = contentElement.getBoundingClientRect();
const availableWidth = window.innerWidth - contentRect.right;
const availableHeight = window.innerHeight;
return { width: availableWidth, height: availableHeight };
};
// Configuration