Skip to content

Commit

Permalink
Fix: Manage background download for Firefox and Chrome ; Modals shado…
Browse files Browse the repository at this point in the history
…wroot error ; Allow www.chatgpt.com scrap as a signed-out user (#233)

* fix: modals bug shadowRoot can be undefined (TODO change)

* fix: distinct download logic for chrome vs firefox

* refactor: shorter code

* fix: allow scraping for chatgpt.com/ as a signed out user

* 3.7.2

* docs: 4000 users update notes
  • Loading branch information
Hugo-COLLIN authored Jan 29, 2025
1 parent 9deb43b commit a9b7c94
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "save-my-chatbot",
"version": "3.7.0",
"version": "3.7.2",
"license": "RMD-C v1.0 License",
"author": "Hugo COLLIN",
"homepage": "https://save.hugocollin.com",
Expand Down
2 changes: 1 addition & 1 deletion public/files/modalMessages/modalError.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "🤔 Well... The export didn't go as planned..."
buttons:
- { text: "I'll try again" }
- { text: "Let me try again" }
- {
text: "🐞 Report this bug",
url: "${appInfos.URLS.REPORT}",
Expand Down
9 changes: 7 additions & 2 deletions public/files/updateNotes.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Update notes
# 3.7.0
# 3.7.2
🚀 4000 users reached!
You're more and more to use this extension, and I'm glad to see that it's useful for you.
Thank you all for your feedback and feature requests!
If you have any, feel free to contact me at <a href="mailto:[email protected]" target="_blank">[email protected]</a> or on the <a href="https://save.hugocollin.com/discussion" target="_blank">GitHub repository</a>.

🔗 Send to automation tools
Thanks to a user contribution, you can now send the exported content to your favorite automation tool through a webhook!
Simply go to the Options page and set your webhook URL.

🧩 Changes under the hood
Code moving and improvements to make the extension more robust and easier to maintain.
Code moves, fixes and improvements to make the extension more robust and easier to maintain.

# 3.6.1
🔗 Export Claude input content
Expand Down
6 changes: 3 additions & 3 deletions src/core/components/modals/cs/types/Modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class Modal {
let {modal, modalBackground} = await this.createModal();

// TODO : this may cause issues !!
const shadow = (document.querySelector("#" + appInfos.APP_SNAME + "-modal-container") as HTMLElement).shadowRoot as ShadowRoot;
shadow.appendChild(modalBackground);
shadow.appendChild(modal);
const shadow = (document.querySelector("#" + appInfos.APP_SNAME + "-modal-container") as HTMLElement)?.shadowRoot as ShadowRoot;
shadow?.appendChild(modalBackground);
shadow?.appendChild(modal);
}

async createModalContent(modalBodyDiv: HTMLElement, outerDiv: HTMLElement, modalBackground: HTMLElement, ...params: any[]) {
Expand Down
22 changes: 15 additions & 7 deletions src/core/services/outputMethods/outputMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ import axios from 'axios';
* @param text markdown content
* @param filename name of the file
*/
export function download(text: string, filename: string) {
const url = 'data:text/markdown;charset=utf-8,' + encodeURIComponent(text);
export async function download(text: string, filename: string) {
// @ts-ignore TODO APP_TARGET is defined in esbuild
const isFirefox = APP_TARGET === 'firefox';
const url = isFirefox
? URL.createObjectURL(new Blob([text], {type: 'text/markdown;charset=utf-8'}))
: 'data:text/markdown;charset=utf-8,' + encodeURIComponent(text);

chrome.downloads.download({
url: url,
filename: filename + '.md',
saveAs: false
});
try {
await chrome.downloads.download({
url,
filename: filename + '.md',
saveAs: false
});
} finally {
if (isFirefox) URL.revokeObjectURL(url);
}
}

// --- Content-script methods ---
Expand Down
1 change: 1 addition & 0 deletions src/data/allowedDomains.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ChatGPT": "chatgpt.com/c",
"ChatGPTShare": "chatgpt.com/share",
"ChatGPTBots": "chatgpt.com/g",
"ChatGPTSignedOut": "chatgpt.com",
"ClaudeChat": "claude.ai/chat"
}
}
1 change: 1 addition & 0 deletions src/features/scraper/extractPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function extractPage(domain: { name: any; url?: any; }) {
case "ChatGPT":
case "ChatGPTShare":
case "ChatGPTBots":
case "ChatGPTSignedOut":
module = require("./domains/ChatGPT");
json = require("./domains/ChatGPT.json");
break;
Expand Down

0 comments on commit a9b7c94

Please sign in to comment.