0

I want to write a Chrome Extension that will copy a specific class text from webpage.

Code:

let element = document.getElementsByClassName("caap5, caap6");
var vOuterText = element[0].outerText;
console.log(vOuterText);

//copy text
const textarea = document.body.appendChild(document.createElement('textarea'));
textarea.value = vOuterText;
textarea.focus();
textarea.select();
document.execCommand('copy');
textarea.remove();

I want to execute this script when I click on the extension icon. I'm using Manifest version 3

0 Answers0