Untitled

 avatar
unknown
plain_text
a year ago
1.1 kB
10
Indexable
// ==UserScript==
// @name        getMaintopic
// @namespace   Violentmonkey Scripts
// @match       *://*.vn/*
// @grant       none
// @version     1.0
// @author      -
// @description 7/30/2024, 7:47:38 AM
// @run-at document-idle
// ==/UserScript==
function sleep(ms) {return new Promise(rs=>setTimeout(rs,ms));}

(async function(){
  if (window != window.top) return;
  const pageRect=document.body.getBoundingClientRect();
  const scrollHeight=700;
  let mainArr=[];

  // for (let i=1; i*scrollHeight<pageRect.height; i++) {scrollBy(0,scrollHeight); await sleep(200);}
  scrollTo(Math.abs(parseInt((pageRect.width-window.innerWidth)/2)), Math.abs(parseInt((pageRect.height-window.innerHeight)/2)));
  mainArr=document.elementsFromPoint(window.innerWidth/2, window.innerHeight/2)
  console.log(mainArr);
  mainArr=mainArr.filter(e=>{
    if(e.tagName.match(/img|picture|video|audio|span|input|button/i)) return false;
    let eS=getComputedStyle(e);
    return eS.width.slice(0,-2)*eS.height.slice(0,-2)> pageRect.width*pageRect.height*.3
  })
  mainArr=mainArr.slice(0,-2); //html, body
  console.log(mainArr);
})();
Editor is loading...
Leave a Comment