Advertisement
Guest User

myscript.js

a guest
Sep 11th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.getElementById('id_Red').onclick = () => {
  2.   chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
  3.     chrome.scripting.executeScript({
  4.       target: {tabId: tabs[0].id},
  5.       function: getPageInnerText
  6.     });
  7.   });
  8. }
  9.  
  10. document.getElementById('id_Blue').onclick = () => {
  11.   chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
  12.     chrome.scripting.executeScript({
  13.       target: {tabId: tabs[0].id},
  14.       function: getPageOuterHtml
  15.     });
  16.   });
  17. }
  18.  
  19. document.getElementById('id_Green').onclick = () => {
  20.   chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
  21.     chrome.scripting.executeScript({
  22.       target: {tabId: tabs[0].id},
  23.       function: getPageParagraph
  24.     });
  25.   });
  26. }
  27.  
  28. function getPageInnerText(){
  29.   document.body.style.backgroundColor = 'red';
  30.   var clipText = document.body.innerText;
  31.   console.log(clipText);
  32.   const el = document.createElement('textarea');
  33.   el.value = clipText;
  34.   el.setAttribute('readonly', '');
  35.   el.style.position = 'absolute';
  36.   el.style.left = '-9999px';
  37.   document.body.appendChild(el);
  38.   el.select();
  39.   document.execCommand('copy');
  40.   document.body.removeChild(el);
  41.   let i = 0;
  42.   let sleep = ["1s"];
  43.   let loopSleep = sleep.length +1;
  44.   function iterateOverArray() {
  45.     i++;
  46.     document.body.style.backgroundColor = 'initial';
  47.   }
  48.   var pauseSleep = setInterval(iterateOverArray, 500);
  49.   setTimeout(() => {
  50.     clearInterval(pauseSleep);
  51.   }, loopSleep * 501);
  52. }
  53.  
  54. function getPageOuterHtml(){
  55.   document.body.style.backgroundColor = 'blue';
  56.   var clipText = document.body.outerHTML;
  57.   console.log(clipText);
  58.   const el = document.createElement('textarea');
  59.   el.value = clipText;
  60.   el.setAttribute('readonly', '');
  61.   el.style.position = 'absolute';
  62.   el.style.left = '-9999px';
  63.   document.body.appendChild(el);
  64.   el.select();
  65.   document.execCommand('copy');
  66.   document.body.removeChild(el);
  67.   let i = 0;
  68.   let sleep = ["1s"];
  69.   let loopSleep = sleep.length +1;
  70.   function iterateOverArray() {
  71.     i++;
  72.     document.body.style.backgroundColor = 'initial';
  73.   }
  74.   var pauseSleep = setInterval(iterateOverArray, 500);
  75.   setTimeout(() => {
  76.     clearInterval(pauseSleep);
  77.   }, loopSleep * 501);
  78. }
  79.  
  80. function getPageParagraph() {
  81.   let inputGreen = prompt("Paragraph length:", 30);
  82.   document.body.style.backgroundColor = 'green';
  83.   let parArray = [];
  84.   let clipTextResults = "";
  85.   var clipText = document.body.innerText.split(/[\r\n]+/);
  86.   for (var i = 0;i < clipText.length; i++){
  87.     if (clipText[i].length > 30) {
  88.       appVal = clipText[i]
  89.       console.log(appVal);
  90.       parArray.push(appVal)
  91.     }
  92.   }
  93.   for (var i = 0;i < parArray.length; i++){
  94.     clipTextResults += parArray[i] + "\r\n"
  95.   }
  96.   const el = document.createElement('textarea');
  97.   el.value = clipTextResults;
  98.   el.setAttribute('readonly', '');
  99.   el.style.position = 'absolute';
  100.   el.style.left = '-9999px';
  101.   document.body.appendChild(el);
  102.   el.select();
  103.   document.execCommand('copy');
  104.   document.body.removeChild(el);
  105.   let j = 0;
  106.   let sleep = ["1s"];
  107.   let loopSleep = sleep.length +1;
  108.   function iterateOverArray() {
  109.     j++;
  110.     document.body.style.backgroundColor = 'initial';
  111.   }
  112.   var pauseSleep = setInterval(iterateOverArray, 500);
  113.   setTimeout(() => {
  114.     clearInterval(pauseSleep);
  115.   }, loopSleep * 501);
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement