Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.getElementById('id_Red').onclick = () => {
- chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
- chrome.scripting.executeScript({
- target: {tabId: tabs[0].id},
- function: getPageInnerText
- });
- });
- }
- document.getElementById('id_Blue').onclick = () => {
- chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
- chrome.scripting.executeScript({
- target: {tabId: tabs[0].id},
- function: getPageOuterHtml
- });
- });
- }
- document.getElementById('id_Green').onclick = () => {
- chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
- chrome.scripting.executeScript({
- target: {tabId: tabs[0].id},
- function: getPageParagraph
- });
- });
- }
- function getPageInnerText(){
- document.body.style.backgroundColor = 'red';
- var clipText = document.body.innerText;
- console.log(clipText);
- const el = document.createElement('textarea');
- el.value = clipText;
- el.setAttribute('readonly', '');
- el.style.position = 'absolute';
- el.style.left = '-9999px';
- document.body.appendChild(el);
- el.select();
- document.execCommand('copy');
- document.body.removeChild(el);
- let i = 0;
- let sleep = ["1s"];
- let loopSleep = sleep.length +1;
- function iterateOverArray() {
- i++;
- document.body.style.backgroundColor = 'initial';
- }
- var pauseSleep = setInterval(iterateOverArray, 500);
- setTimeout(() => {
- clearInterval(pauseSleep);
- }, loopSleep * 501);
- }
- function getPageOuterHtml(){
- document.body.style.backgroundColor = 'blue';
- var clipText = document.body.outerHTML;
- console.log(clipText);
- const el = document.createElement('textarea');
- el.value = clipText;
- el.setAttribute('readonly', '');
- el.style.position = 'absolute';
- el.style.left = '-9999px';
- document.body.appendChild(el);
- el.select();
- document.execCommand('copy');
- document.body.removeChild(el);
- let i = 0;
- let sleep = ["1s"];
- let loopSleep = sleep.length +1;
- function iterateOverArray() {
- i++;
- document.body.style.backgroundColor = 'initial';
- }
- var pauseSleep = setInterval(iterateOverArray, 500);
- setTimeout(() => {
- clearInterval(pauseSleep);
- }, loopSleep * 501);
- }
- function getPageParagraph() {
- let inputGreen = prompt("Paragraph length:", 30);
- document.body.style.backgroundColor = 'green';
- let parArray = [];
- let clipTextResults = "";
- var clipText = document.body.innerText.split(/[\r\n]+/);
- for (var i = 0;i < clipText.length; i++){
- if (clipText[i].length > 30) {
- appVal = clipText[i]
- console.log(appVal);
- parArray.push(appVal)
- }
- }
- for (var i = 0;i < parArray.length; i++){
- clipTextResults += parArray[i] + "\r\n"
- }
- const el = document.createElement('textarea');
- el.value = clipTextResults;
- el.setAttribute('readonly', '');
- el.style.position = 'absolute';
- el.style.left = '-9999px';
- document.body.appendChild(el);
- el.select();
- document.execCommand('copy');
- document.body.removeChild(el);
- let j = 0;
- let sleep = ["1s"];
- let loopSleep = sleep.length +1;
- function iterateOverArray() {
- j++;
- document.body.style.backgroundColor = 'initial';
- }
- var pauseSleep = setInterval(iterateOverArray, 500);
- setTimeout(() => {
- clearInterval(pauseSleep);
- }, loopSleep * 501);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement