Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading chrome's ctrl+p data

Is it possible with chrome extension to read ctrl+p data and save it as pdf or html without showing print screen?

like image 922
m.qayyum Avatar asked Mar 15 '19 16:03

m.qayyum


1 Answers

To read what is on the clipboard this works.

async function getClipboardContents() {
  try {
    const text = await navigator.clipboard.readText();
    console.log('Pasted content: ', text);
  } catch (err) {
    console.error('Failed to read clipboard contents: ', err);
  }
}

To prevent CTRL+P put this into your head tag

<link rel="alternate" media="print" href="alternativeUrlForPrint.ext" />

Use the L2i Library to capture what is in your console, it will capture anything you put there using the above code. Then you just download it with a function.

l2i.download();

Lastly you can put this all into TamperMonkey to make it an extension.

like image 135
shadow2020 Avatar answered Oct 21 '22 20:10

shadow2020