mirror of
https://github.com/lencx/Noi.git
synced 2026-01-04 19:31:20 +01:00
fix: ChatGPT sidebar clickability
This commit is contained in:
@@ -104,7 +104,7 @@ Learn more: [electronjs/doc](https://www.electronjs.org/docs/latest/api/extensio
|
|||||||
| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.9 | The best assistant for batch asking and quick typing of prompts. |
|
| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.9 | The best assistant for batch asking and quick typing of prompts. |
|
||||||
| [@noi/ask-custom](https://github.com/lencx/Noi/tree/main/extensions/noi-ask-custom) | 0.1.0 | The best assistant for batch asking and quick typing of prompts. |
|
| [@noi/ask-custom](https://github.com/lencx/Noi/tree/main/extensions/noi-ask-custom) | 0.1.0 | The best assistant for batch asking and quick typing of prompts. |
|
||||||
| [@noi/export-chatgpt](https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt) | 0.1.1 | ChatGPT chat history export, supports PDF, Image, and Markdown formats. |
|
| [@noi/export-chatgpt](https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt) | 0.1.1 | ChatGPT chat history export, supports PDF, Image, and Markdown formats. |
|
||||||
| [@noi/reset](https://github.com/lencx/Noi/tree/main/extensions/noi-reset) | 0.1.1 | Reset certain website styles to enhance compatibility with Noi. |
|
| [@noi/reset](https://github.com/lencx/Noi/tree/main/extensions/noi-reset) | 0.1.3 | Reset certain website styles to enhance compatibility with Noi. |
|
||||||
<!-- EXTENSIONS_END -->
|
<!-- EXTENSIONS_END -->
|
||||||
|
|
||||||
[](https://star-history.com/#lencx/Noi&Timeline)
|
[](https://star-history.com/#lencx/Noi&Timeline)
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ Learn more: [electronjs/doc](https://www.electronjs.org/docs/latest/api/extensio
|
|||||||
| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.9 | The best assistant for batch asking and quick typing of prompts. |
|
| [@noi/ask](https://github.com/lencx/Noi/tree/main/extensions/noi-ask) | 0.1.9 | The best assistant for batch asking and quick typing of prompts. |
|
||||||
| [@noi/ask-custom](https://github.com/lencx/Noi/tree/main/extensions/noi-ask-custom) | 0.1.0 | The best assistant for batch asking and quick typing of prompts. |
|
| [@noi/ask-custom](https://github.com/lencx/Noi/tree/main/extensions/noi-ask-custom) | 0.1.0 | The best assistant for batch asking and quick typing of prompts. |
|
||||||
| [@noi/export-chatgpt](https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt) | 0.1.1 | ChatGPT chat history export, supports PDF, Image, and Markdown formats. |
|
| [@noi/export-chatgpt](https://github.com/lencx/Noi/tree/main/extensions/noi-export-chatgpt) | 0.1.1 | ChatGPT chat history export, supports PDF, Image, and Markdown formats. |
|
||||||
| [@noi/reset](https://github.com/lencx/Noi/tree/main/extensions/noi-reset) | 0.1.2 | Reset certain website styles to enhance compatibility with Noi. |
|
| [@noi/reset](https://github.com/lencx/Noi/tree/main/extensions/noi-reset) | 0.1.3 | Reset certain website styles to enhance compatibility with Noi. |
|
||||||
<!-- EXTENSIONS_END -->
|
<!-- EXTENSIONS_END -->
|
||||||
52
extensions/noi-reset/base.js
Normal file
52
extensions/noi-reset/base.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
(function(history) {
|
||||||
|
// Initialize storage for event listeners
|
||||||
|
const eventListeners = {
|
||||||
|
pushstate: {},
|
||||||
|
replacestate: {},
|
||||||
|
popstate: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function to trigger all listeners for a specific event
|
||||||
|
function triggerEventListeners(eventName, event) {
|
||||||
|
Object.values(eventListeners[eventName]).forEach(listener => listener(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to override history methods and add our own logic
|
||||||
|
function overrideHistoryMethod(methodName, eventName) {
|
||||||
|
const originalMethod = history[methodName];
|
||||||
|
history[methodName] = function(state, ...rest) {
|
||||||
|
const result = originalMethod.apply(this, [state, ...rest]);
|
||||||
|
// Construct event object
|
||||||
|
const event = { state: state, url: window.location.href };
|
||||||
|
triggerEventListeners(eventName, event);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override both pushState and replaceState methods
|
||||||
|
overrideHistoryMethod('pushState', 'pushstate');
|
||||||
|
overrideHistoryMethod('replaceState', 'replacestate');
|
||||||
|
|
||||||
|
// Listen to the native popstate event and trigger our listeners
|
||||||
|
window.addEventListener('popstate', event => {
|
||||||
|
triggerEventListeners('popstate', { url: window.location.href });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Provide interface for registering and unregistering event listeners
|
||||||
|
window.NoiUtils = {
|
||||||
|
changeURL(id, callback) {
|
||||||
|
if (typeof callback === 'function' && id) {
|
||||||
|
// Avoid registering the same callback under the same ID
|
||||||
|
eventListeners.pushstate[id] = callback;
|
||||||
|
eventListeners.replacestate[id] = callback;
|
||||||
|
eventListeners.popstate[id] = callback;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeURL(id) {
|
||||||
|
// Remove the listener by ID from all event types
|
||||||
|
delete eventListeners.pushstate[id];
|
||||||
|
delete eventListeners.replacestate[id];
|
||||||
|
delete eventListeners.popstate[id];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(window.history);
|
||||||
@@ -11,4 +11,5 @@ function removeAppRegion() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(removeAppRegion, 3000);
|
setTimeout(removeAppRegion, 1000);
|
||||||
|
window.NoiUtils?.changeURL?.('noi@reset:drag', () => setTimeout(removeAppRegion, 1000));
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "@noi/reset",
|
"name": "@noi/reset",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"homepage": "https://github.com/lencx/Noi/tree/main/extensions/noi-reset",
|
"homepage": "https://github.com/lencx/Noi/tree/main/extensions/noi-reset",
|
||||||
"description": "Reset certain website styles to enhance compatibility with Noi.",
|
"description": "Reset certain website styles to enhance compatibility with Noi.",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"matches": [
|
"matches": [
|
||||||
"<all_urls>"
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
"js": ["scrollbar.js", "darg.js"],
|
"js": ["base.js", "scrollbar.js", "darg.js"],
|
||||||
"run_at": "document_end",
|
"run_at": "document_end",
|
||||||
"world": "MAIN"
|
"world": "MAIN"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user