Coder Social home page Coder Social logo

chatgpt-pdf's People

Contributors

adrianmarinwork avatar d-32 avatar liady avatar pedrokohler avatar spidy0x0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatgpt-pdf's Issues

Page Layout & PDF creation

Using your excellent extension set me thinking about whether the apps Pandoc and PagedJS I have been experimenting with in book publication might be helpful. I've attached notes about them over the last couple of years which might be useful for you in addressing problems with layout and conversion to nicely paginated pdfs.
Paged.js.pdf
Pandoc & PanWriter.pdf
Zettlr - Pagedjs.pdf

Able to generate PDF & PNG at only once, next time gives error

I'm able to generate the PDF and PNG image only at ones, for the second time it gives the errors as
Uncaught TypeError: Cannot read properties of null (reading 'style') at Elements.fixLocation (content_script.js:201:17) at downloadThread (content_script.js:112:12) at downloadButton.onclick (content_script.js:89:5)

and

content_script.js:201 Uncaught TypeError: Cannot read properties of null (reading 'style') at Elements.fixLocation (content_script.js:201:17) at downloadThread (content_script.js:112:12) at downloadPdfButton.onclick (content_script.js:97:5)

Support export to Markdown

The addition of Markdown would be essential for many when being utilized for writing documentation and providing/consuming code samples.

Thanks for the work on this!!

For anyone else, still have requirement for export ChatGPT conversations into file

I've extracted the content related to obtaining the canvas and downloading it from the source code, creating a runnable Chrome DevTools code snippet.

  1. It supports directly downloading the long image of the conversation.
  2. I didn't include any preloading code for PDFJS, so the functionality of downloading as a PDF needs to be implemented separately. However, it's not complicated (you can ask ChatGPT to help you write it).
    Simply copy the code into Chrome DevTools' code snippet section, run it, and you'll get the result in 3–5 seconds.

PS:

  1. At first, I tried to implement the logic of obtaining the canvas myself, but after failing for a whole night, I decided to come here for answers.
  2. The extension itself has some minor issues, but I don't want to fix these logical problems. I just want the fastest executable solution.
  3. Code snippets have always been my choice. I don't want to turn this feature into an extension because if ChatGPT's page structure changes, the current code for obtaining the canvas will inevitably need to be adjusted, making it a nightmare if it were an extension.
  4. The above content was translated by ChatGPT. Enjoy the ALL-GPT-ERA!
class Elements {
  constructor() {
    this.init();
  }
  init() {
    // this.threadWrapper = document.querySelector(".cdfdFe");
    this.spacer = document.querySelector(
      ".w-full.h-32.md\\:h-48.flex-shrink-0"
    );
    this.thread = document.querySelector(
      "[class*='react-scroll-to-bottom']>[class*='react-scroll-to-bottom']>div"
    );
    this.positionForm = document.querySelector("form").parentNode;
    // this.styledThread = document.querySelector("main");
    // this.threadContent = document.querySelector(".gAnhyd");
    this.scroller = Array.from(
      document.querySelectorAll('[class*="react-scroll-to"]')
    ).filter((el) => el.classList.contains("h-full"))[0];
    this.hiddens = Array.from(document.querySelectorAll(".overflow-hidden"));
    this.images = Array.from(document.querySelectorAll("img[srcset]"));
  }
  fixLocation() {
    this.hiddens.forEach((el) => {
      el.classList.remove("overflow-hidden");
    });
    this.spacer.style.display = "none";
    this.thread.style.maxWidth = "960px";
    this.thread.style.marginInline = "auto";
    this.positionForm.style.display = "none";
    this.scroller.classList.remove("h-full");
    this.scroller.style.minHeight = "100vh";
    this.images.forEach((img) => {
      const srcset = img.getAttribute("srcset");
      img.setAttribute("srcset_old", srcset);
      img.setAttribute("srcset", "");
    });
    //Fix to the text shifting down when generating the canvas
    document.body.style.lineHeight = "0.5";
  }
  restoreLocation() {
    this.hiddens.forEach((el) => {
      el.classList.add("overflow-hidden");
    });
    this.spacer.style.display = null;
    this.thread.style.maxWidth = null;
    this.thread.style.marginInline = null;
    this.positionForm.style.display = null;
    this.scroller.classList.add("h-full");
    this.scroller.style.minHeight = null;
    this.images.forEach((img) => {
      const srcset = img.getAttribute("srcset_old");
      img.setAttribute("srcset", srcset);
      img.setAttribute("srcset_old", "");
    });
    document.body.style.lineHeight = null;
  }
}

const Format = {
  PNG: "png",
  PDF: "pdf",
};

function downloadThread({ as = Format.PNG } = {}) {
  const elements = new Elements();
  elements.fixLocation();
  const pixelRatio = window.devicePixelRatio;
  // since I only need to export to image format, following two lines code mean less
  const minRatio = as === Format.PDF ? 2 : 2.5;
  window.devicePixelRatio = Math.max(pixelRatio, minRatio);

  html2canvas(elements.thread, {
    letterRendering: true,
  }).then(async function (canvas) {
    elements.restoreLocation();
    window.devicePixelRatio = pixelRatio;
    const imgData = canvas.toDataURL("image/png");
    requestAnimationFrame(() => {
      if (as === Format.PDF) {
        return handlePdf(imgData, canvas, pixelRatio);
      } else {
        handleImg(imgData);
      }
    });
  });
}

function handleImg(imgData) {
  const binaryData = atob(imgData.split("base64,")[1]);
  const data = [];
  for (let i = 0; i < binaryData.length; i++) {
    data.push(binaryData.charCodeAt(i));
  }
  const blob = new Blob([new Uint8Array(data)], { type: "image/png" });
  const url = URL.createObjectURL(blob);

  window.open(url, "_blank");

  const a = document.createElement("a");
  a.href = url;
  a.download = "chat-gpt-image.png";
  a.click();
}
  // since I only need to export to image format, following two lines code mean less
  // if you wanna to export to pdf file, import pdfjs lib before everything, otherwise you will get an error about 'operty 'jsPDF' of 'window.jspdf' as it is undefined.
function handlePdf(imgData, canvas, pixelRatio) {
  const { jsPDF } = window.jspdf;
  const orientation = canvas.width > canvas.height ? "l" : "p";
  var pdf = new jsPDF(orientation, "pt", [
    canvas.width / pixelRatio,
    canvas.height / pixelRatio,
  ]);
  var pdfWidth = pdf.internal.pageSize.getWidth();
  var pdfHeight = pdf.internal.pageSize.getHeight();
  pdf.addImage(imgData, "PNG", 0, 0, pdfWidth, pdfHeight);
  pdf.save("chat-gpt.pdf");
}

downloadThread();

****Not private**SECURITY-ISSUE*** DO NOT USE UNTIL CHANGES ARE MADE***

@D-32 @liady @adrianmarinwork it is important to note that the current implementation of the code uploads data to the author's S3 bucket. While this may be a convenient solution for the author, it poses a potential security risk, as it could allow the author to access sensitive data, such as passwords or API keys, that users may inadvertently include in their data.

To address this concern, it would be advisable to modify the code so that it does not upload user data to a third-party service, such as the author's S3 bucket. One potential solution could be to modify the code so that it saves the user's data locally on their own machine instead of uploading it to a remote server. This would help ensure that the user's data remains secure and under their control.

It is important to be mindful of potential security risks when using third-party software or services. Users should always carefully review the code and configuration of any software or service they use, and take appropriate steps to secure their data and systems.

Support Firefox

Add a support for Firefox, I believe it is only changing the manifest file (since FF uses manifest v2)

Major Security, Public Safety and Privacy Concerns

The way this extension currently works, when someone clicks the Share Link or Download PDF buttons the full conversation log is uploaded to an Amazon S3 container and set to public. This all happens through a function hosted at https://chat-gpt-static.netlify.app/.netlify/functions/chatgpt-upload which we are unable to see the code for.

In addition to the above, the way this function is referenced is through a text file also hosted on Amazon S3. The owner of the chatgpt-static S3 container on AWS could change the contents of the url.txt file (https://chatgpt-static.s3.amazonaws.com/url.txt) at any time to include a malicious script, which poses another serious security issue, on top of the one above.

Further, since the full conversation log is uploaded to an S3 container and set to public, with no way for us to delete the data. If someone happens to have some personal or other potentially harmful information in the conversation log being uploaded, then that poses a serious public safety issue on top of the security issue.

I would highly recommend you come up with a more direct and local way to achieve the same goals in light of the major issues above.

Letter of Authorization Request for Commercial Use of Logo Images

Dear [ChatGPT Export and Share] Owner/Manager:

I'm the webmaster of the "GPT資源庫" website. I'm happy to reach out to you as we're building a website and would like to be able to use your company logo image as the featured image for our app assets.

Our website is an application resource display and screening website. We will select high-quality application resources to display on our website, and your company's Logo will be used to represent the quality and credibility of the application resources we recommend.

Furthermore, all application resources displayed on the website will be linked directly to your official website/application page, so that users can directly download or use your application, and our website will also insert advertisements for profit Purpose.

We will use your company logo image on this page:
https://chatgptdemo.com/product/chatgpt-export-and-share/

If you agree to us using your Logo, please let us know and feel free to contact me if you have any questions. We are willing to answer any questions about this application.

Thank you for your patience and look forward to hearing from you.

Congratulations,
"GPT資源庫" Webmaster

Download PNG/PDF doesn't work before i generate atleast once

When i load my previous session from this tab
208922455-cbf2556c-0b6d-46b6-bd07-d647123365bc

Then i try to download PNG/PDF, it bugged the UI, and it fails to download

2022-12-21.20-00-03.mp4

Next i try to add a single prompt on that same session, then try to download PNG/PDF, it worked

v1.3.4 Errors on PDF and PNG Generation

Currently getting this error in Dev console for v1.3.4. I am using Brave Browser.

content_script.js:201 Uncaught TypeError: Cannot read properties of null (reading 'style')
    at Elements.fixLocation (content_script.js:201:17)
    at downloadThread (content_script.js:112:12)
    at downloadButton.onclick (content_script.js:89:5)

buttons not showup

It looks like the shouldRemoveButton function was broken with the latest webpage.

Does not work in Vivaldi

I followed the instructions, the extension got installed. I can see buttons at the bottom of the chat. However, none of the buttons seems to be working - all they do is to create some weird selection around the chat name on the left side of the page.

When I go into extensions -> ChatGPT Download -> Errors, I see this:

Error:

Uncaught TypeError: Cannot read properties of null (reading 'style')
Context
https://chat.openai.com/chat/8ed2ef99-1915-41e1-a985-4cfe41efe8ad
Stack Trace
content_script.js:200 (anonymous function)

Versions

ChatGPT Jan 30 Version. Free Research Preview. Our goal is to make AI systems more natural and safe to interact with. Your feedback will help us improve.

I use ChatGPT in dark mode.

Browser: Vivaldi 5.6.2867.62 (Stable channel) (32-bit)
Windows 10 Version 22H2 (Build 19045.2486)

ChatGPT Download 1.3.4

Existing conversation can't be Downloaded

I installed the extension as per the instructions to take pdf of an existing conversation. The buttons are not visible in the conversation but they are present in a new chatGPT tab.

Issue Extension not working. Nothing works in extension.

Uncaught TypeError: Cannot read properties of null (reading 'style')
at Elements.fixLocation (content_script.js:200:17)
at downloadThread (content_script.js:112:12)
at downloadButton.onclick (content_script.js:89:5)
fixLocation @ content_script.js:200
downloadThread @ content_script.js:112
downloadButton.onclick @ content_script.js:89

Generated PDF issue

The PDF is also PNG? I can't select the text... It's basically a useless function unless I'm doing something wrong

Broken in FF

Steps taken

  1. Download and install firefox-chatgpt-share-v1.3.2.zip according to the "Install to Firefox" instructions
  2. Scroll to the bottom of the ChatGPT thread
  3. Press "Download PDF" or "Generate PNG"

What happened

  1. It scrolled to the top and removed the text entry box
  2. It stayed there. No PDF was generated and the text entry box is gone so I cannot continue the thread 😞

Console output

#1 0ms Starting document clone with size 1617x714 scrolled to 0,0 html2canvas.min.js:20:191994
SecurityError: The operation is insecure. html2canvas.min.js:20

Browser Version

FireFox Developer Edition, 108.0b6 (64-bit) (macOS Monterey)


Additionally, "Share Link" is broken in a different way:

TypeError: NetworkError when attempting to fetch resource. content_script.js:207:35

That link calls https://chatgpt-static.s3.amazonaws.com/url.txt which does work from a different tab in the same browser.

This follows a couple moments later:

Source map error: Error: NetworkError when attempting to fetch resource.
Resource URL: moz-extension://9f591789-ad54-4a2a-bf8f-43b3890db7c3/scripts/jspdf.umd.min.js
Source Map URL: jspdf.umd.min.js.map

Chrome addon does not work - Cannot read properties of null (reading 'style')

Chrome addon does not work - The below error is thrown on Console log:

Uncaught TypeError: Cannot read properties of null (reading 'style')
    at Elements.fixLocation (content_script.js:200:17)
    at downloadThread (content_script.js:112:12)
    at downloadButton.onclick (content_script.js:89:5)
fixLocation @ content_script.js:200
downloadThread @ content_script.js:112
downloadButton.onclick @ content_script.js:89
72The resource <URL> was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.
content_script.js:200 Uncaught TypeError: Cannot read properties of null (reading 'style')
    at Elements.fixLocation (content_script.js:200:17)
    at downloadThread (content_script.js:112:12)
    at downloadPdfButton.onclick (content_script.js:97:5)
fixLocation @ content_script.js:200
downloadThread @ content_script.js:112
downloadPdfButton.onclick @ content_script.js:97
content_script.js:275 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'cssRules')
    at getCssFromSheet (content_script.js:275:27)
    at getData (content_script.js:258:21)
    at sendRequest (content_script.js:239:16)
    at exportHtml.onclick (content_script.js:105:5)
getCssFromSheet @ content_script.js:275
getData @ content_script.js:258
sendRequest @ content_script.js:239
exportHtml.onclick @ content_script.js:105

Chrome extension not working..

Once files are extracted and loading unpacked in chrome extension, extension does not work , there are some files missing in the extracted files..

Flashing Buttons

I have just applied what is the latest release, and I find that the buttons are flashing, ie. all the folloing in a panel:
Regenerate Response - Generate PNG - Download PDF - Share Link

What do I need to do to correct it?

RJ
2023-03-10_11-10-58 ChatGPT pdf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.