Ground.news

Unbiased news access should be free and unlimited

目前为 2025-02-20 提交的版本。查看 最新版本

// ==UserScript==
// @name         Ground.news
// @namespace    http://tampermonkey.net/
// @version      1.1.1
// @description  Unbiased news access should be free and unlimited
// @author       blank
// @match        https://ground.news/*
// @grant        none
// @license MIT
// ==/UserScript==
const delay = ms => new Promise(res => setTimeout(res, ms));
async function free(){
    await delay(2000);//reduce unlock time
    localStorage.articlesAccessed =[[]];
    try{
        document.querySelector('[class*="hideElementSiteWide flex sticky h-6 tablet:h-auto items-center top-0 z-1000 bg-focus text-dark-primary"]').style.display='none';
        document.querySelector('[class*="fixed z-[1000] left-0 right-0 dark:bg-dark-heavy bg-tertiary-light"]').setAttribute("class","hidden");
    }catch{}
    try{
        document.querySelector('[class*="fixed z-[1000] left-0 right-0 dark:bg-dark-heavy bg-tertiary-light"]').setAttribute("class","hidden");
        document.querySelector('[class*="mdd:hidden z-1000 top-0 sticky"]').style.display='none';
        alert("An error ocurred, if you are unable to access premium functionalities, refresh the page");
    }catch{}
    if(document.URL.match("ground.news/article").length==1){
        let probJson=""
        let jsonStr=document.getElementsByTagName("script");
        let f=0;
        for(let x=0;x<jsonStr.length;x++){
            if(jsonStr[x].innerHTML.length>probJson.length){
                probJson=jsonStr[x].innerText;
                f=x;
            }
        }
        jsonStr=probJson.match("\\\"factuality.*corporation\\\":[0-9]*}");
        if(jsonStr==null){
            jsonStr=probJson.match("\\\\\"factuality.*corporation\\\\\":[0-9]*}")
        }
        jsonStr=jsonStr[0].replaceAll("\\","");
        jsonStr=JSON.parse(`{${jsonStr}}`);
        const [factualityDiv,ownershipDiv]=[document.querySelectorAll("[class*=\"flex w-full items-center justify-between\"]"),document.querySelectorAll("[class*=\"bg-light-light p-8px tablet:p-1_6 flex flex-col gap-1_2 w-full h-full text-12 dark:text-dark-gray-100 leading-tightest dark:bg-dark-light cursor-pointer\"]")];
        let [ownershipPercentage,ownershipNames,ownershipItems,ownerFinalColor,ownershipDisplayNames,ownershipPickPercentage]=[[],[],0,[0,""],[],0];
        let [prettyName,aname]=["",""];
        for(let key in jsonStr.ownership){
            ownershipPercentage.push(jsonStr.ownership[key]);
            if(key=="billionaire"){
                ownershipNames.push("wealthyPrivateOwner");
            }else{ownershipNames.push(key);}
            if(key=="billionaire"){
                aname="Wealthy Private Owner";
                ownershipDisplayNames.push("Wealthy Private Owner");
            }else if(key=="telecom"){
                aname="Telecommunications";
                ownershipDisplayNames.push("Telecommunications");
            }else if(key=="privateEquity"){
                aname="Private equity";
                ownershipDisplayNames.push("Private equity");
            }else if(key=="mediaConglomerate"){
                aname="Media Conglomerate";
                ownershipDisplayNames.push("Media Conglomerate");
            }else if(key=="government"){
                aname="Government";
                ownershipDisplayNames.push("Government");
            }else if(key=="independent"){
                aname="Independent news";
                ownershipDisplayNames.push("Independent news");
            }else if(key=="corporation"){
                aname="Corporation";
                ownershipDisplayNames.push("Corporation");
            }else{
                aname="Other";
                ownershipDisplayNames.push("Other");
            }
            if(jsonStr.ownership[key]>ownerFinalColor[0]){
                ownershipPickPercentage=jsonStr.ownership[key];
                ownerFinalColor[1]=key;
                ownerFinalColor[0]=jsonStr.ownership[key];
                prettyName=aname;
            }
            ownershipItems+=jsonStr.ownership[key];
        }
        for(let x=0;x<ownershipPercentage.length;x++){
            ownershipPercentage[x]=(ownershipPercentage[x]/ownershipItems)*100;
        }
        ownershipPickPercentage=(ownershipPickPercentage/ownershipItems)*100;
        const removeBuyPremium= document.querySelectorAll('p:has(span.underline)');
        for(let x=0;x<removeBuyPremium.length;x++){
            removeBuyPremium[x].style.display='none';
        }
        try{
            factualityDiv[0]._tippy.reference.childNodes[1].style.display='none';
        }catch{}
        try{
            factualityDiv[0]._tippy.reference.childNodes[0].className='flex text-14 tablet:text-18 items-center';
        }catch{}
        try{
            ownershipDiv[0].children[0].childNodes[0].className="relative flex items-center";
        }catch{}
        try{
            ownershipDiv[0].children[0].childNodes[1].style.display="none";
        }catch{}
        try{
            if(ownerFinalColor[1]=="billionaire"){
                ownershipDiv[0].children[2].className=`bg-mediaopoly-wealthyPrivateOwner text-center h-2_4`;
            }
            else{
                ownershipDiv[0].children[2].className=`bg-mediaopoly-${ownerFinalColor[1]} text-center h-2_4`;
            }

        }catch{}
        let message = document.createElement("div");
        let tippyIndx=100;
        message.innerHTML=`<div data-tippy-root="" id="tippy-${tippyIndx}" style="pointer-events: none; z-index: 9999; position: relative; inset: 0px auto auto 0px; margin: 0px; display: none; width: 100rem;"><div class="tippy-box justify-end flex dark:bg-light-primary dark:text-dark-primary p-1_2 text-16 tablet:text-12 tippy_arrow__uqz_Z" data-state="visible" tabindex="-1" data-animation="fade" style="max-width: 350px; transition-duration: 300ms;" role="tooltip" data-placement="bottom"><div class="tippy-content" data-state="visible" style="transition-duration: 300ms;"><div><span>${prettyName}, ${ownershipPickPercentage.toFixed()}%</span></div></div><div class="tippy-arrow" style="position: absolute; left: 0px; transform: translate3d(50px, 0px, 0px);"></div></div></div>`;
        ownershipDiv[0].insertBefore(message,ownershipDiv[0].children[3]);
        document.querySelectorAll("[class*=\"bg-light-light p-8px tablet:p-1_6 flex flex-col gap-1_2 w-full h-full text-12 dark:text-dark-gray-100 leading-tightest dark:bg-dark-light cursor-pointer\"]")[0].children[2].onmouseenter=()=>{document.getElementById(`tippy-100`).style.display='block'};
        document.querySelectorAll("[class*=\"bg-light-light p-8px tablet:p-1_6 flex flex-col gap-1_2 w-full h-full text-12 dark:text-dark-gray-100 leading-tightest dark:bg-dark-light cursor-pointer\"]")[0].children[2].onmouseleave=()=>{document.getElementById(`tippy-100`).style.display='none'};
        try{
            ownershipDiv[0].children[4].className="";
        }catch{}
        tippyIndx++;
        ownershipDiv[0].children[4].children[0].innerHTML='';
        for(let add=0;add<ownershipNames.length;add++){
           ownershipDiv[0].children[4].children[0].innerHTML+=`<div class=" bg-mediaopoly-${ownershipNames[add]} text-center py-4px" style="width:${ownershipPercentage[add]}%" onmouseenter="document.getElementById('tippy-${tippyIndx}').style.display='block';" onmouseleave="document.getElementById('tippy-${tippyIndx}').style.display='none';"></div>`;
           ownershipDiv[0].children[4].innerHTML+=`<div data-tippy-root="" id="tippy-${tippyIndx}" style="pointer-events: none; z-index: 9999; position: relative; inset: 0px auto auto 0px; margin-top: 0.5rem; display: none; width: 100rem;"><div class="tippy-box justify-end flex dark:bg-light-primary dark:text-dark-primary p-1_2 text-16 tablet:text-12 tippy_arrow__uqz_Z" data-state="visible" tabindex="-1" data-animation="fade" style="max-width: 350px; transition-duration: 300ms;" role="tooltip" data-placement="bottom"><div class="tippy-content" data-state="visible" style="transition-duration: 300ms;"><div><span>${ownershipDisplayNames[add]}, ${ownershipPercentage[add].toFixed()}%</span></div></div><div class="tippy-arrow" style="position: absolute; left: 0px; transform: translate3d(50px, 0px, 0px);"></div></div></div>`;
           tippyIndx++;
        }
        //Do Facuality
        factualityDiv[0].children[0].className="flex text-14 tablet:text-18 items-center";
        factualityDiv[0].children[1].style.display="none";
        let [factuality,factualityItems,finalColor]=[0,0,[0,""]];
        let [facPrettyName,facAname,facNames,facPrettyNames,facPercentage,facFinalPercentage]=["","",[],[],[],0];
        for(let key in jsonStr.factuality){
            factualityItems+=jsonStr.factuality[key];
            facPercentage.push(jsonStr.factuality[key]);
            if(key=='veryLow'){
               facAname="Very low";
               factuality-=2*jsonStr.factuality[key];
            }else if(key=='low'){
               facAname="Low";
               factuality-=1*jsonStr.factuality[key];
            }else if(key=='high'){
               facAname="High";
               factuality+=1*jsonStr.factuality[key];
            }else if(key=="veryHigh"){
               facAname="Very high";
               factuality+=2*jsonStr.factuality[key];
            }else if(key=="mixed"){
               facAname="Mixed";
            }else if(key=="unknown"){
               facAname="Unknown";
            }
            facNames.push(key);
            facPrettyNames.push(facAname);
            if(jsonStr.factuality[key]>finalColor[0]){
                finalColor[1]=key;
                finalColor[0]=jsonStr.factuality[key];
                facPrettyName=facAname;
                facFinalPercentage=jsonStr.factuality[key];
            }
        }
        if(facPrettyName=="Unknown"){
           finalColor[1]="unkown bg-white";
        }
        try{
            document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[0].className=`bg-factuality-${finalColor[1]} text-center h-2_4`;
        }catch{}
        try{
            document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[1].className="";
        }catch{}
        for(let x=0;x<facPercentage.length;x++){
            facPercentage[x]=(facPercentage[x]/factualityItems)*100;
        }
        facFinalPercentage=(facFinalPercentage/factualityItems)*100;
        try{
            document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[1].children[0].innerHTML="";
        }catch{}
        //<div class="bg-factuality-low text-center py-4px" style="width:40%"></div>
        for(let x=0;x<facNames.length;x++){
            if(facNames[x]!="unknown"){
                document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[1].children[0].innerHTML+=`<div class="bg-factuality-${facNames[x]} text-center py-4px" style="width:${facPercentage[x]}%" onmouseenter="document.getElementById('tippy-${tippyIndx}').style.display='block';" onmouseleave="document.getElementById('tippy-${tippyIndx}').style.display='none';"></div>`;
            }else{
                document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[1].children[0].innerHTML+=`<div class="bg-white text-center py-4px" style="width:${facPercentage[x]}%" onmouseenter="document.getElementById('tippy-${tippyIndx}').style.display='block';" onmouseleave="document.getElementById('tippy-${tippyIndx}').style.display='none';"></div>`;
            }
            document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[1].innerHTML+=`<div data-tippy-root="" id="tippy-${tippyIndx}" style="pointer-events: none; z-index: 9999; position: relative; inset: 0px auto auto 0px; margin-top: 0.5rem; display: none; width: 100rem;"><div class="tippy-box justify-end flex dark:bg-light-primary dark:text-dark-primary p-1_2 text-16 tablet:text-12 tippy_arrow__uqz_Z" data-state="visible" tabindex="-1" data-animation="fade" style="max-width: 350px; transition-duration: 300ms;" role="tooltip" data-placement="bottom"><div class="tippy-content" data-state="visible" style="transition-duration: 300ms;"><div><span>${facPrettyNames[x]}, ${facPercentage[x].toFixed()}%</span></div></div><div class="tippy-arrow" style="position: absolute; left: 0px; transform: translate3d(50px, 0px, 0px);"></div></div></div>`;
            tippyIndx++;
        }
        let factualityMessage=document.createElement("div");
        factualityMessage.innerHTML=`<div data-tippy-root="" id="tippy-${tippyIndx}" style="pointer-events: none; z-index: 9999; position: relative; inset: 0px auto auto 0px; margin: 0px; display: none; width: 100rem;"><div class="tippy-box justify-end flex dark:bg-light-primary dark:text-dark-primary p-1_2 text-16 tablet:text-12 tippy_arrow__uqz_Z" data-state="visible" tabindex="-1" data-animation="fade" style="max-width: 350px; transition-duration: 300ms;" role="tooltip" data-placement="bottom"><div class="tippy-content" data-state="visible" style="transition-duration: 300ms;"><div><span>${facPrettyName}, ${facFinalPercentage.toFixed()}%</span></div></div><div class="tippy-arrow" style="position: absolute; left: 0px; transform: translate3d(50px, 0px, 0px);"></div></div></div>`;
        try{
            document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].insertBefore(factualityMessage, document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[1])
        }catch{}
        document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[0].onmouseenter=()=>{document.getElementById('tippy-116').style.display='block'};
        document.querySelectorAll("[class*=\"bg-tertiary-light dark:bg-dark-light p-8px tablet:p-1_6 flex flex-col gap-1_2  justify-between w-full h-full text-12 dark:text-dark-gray-100 leading-tightest cursor-pointer\"]")[0].children[1].children[0].onmouseleave=()=>{document.getElementById('tippy-116').style.display='none'};
    }
}
if(window.attachEvent) {
    window.attachEvent('onload', free);
} else {
    if(window.onload) {
        var curronload = window.onload;
        var newonload = function(evt) {
            curronload(evt);
            free(evt);
        };
        window.onload = newonload;
    } else {
        window.onload = free;
    }
}


document.onclick=async function(){
    try{
        await delay(2000);
        if(document.URL.match("ground.news/article").length==1){
            if(document.querySelector('[class*="fixed z-[1000] left-0 right-0 dark:bg-dark-heavy bg-tertiary-light"]')!=null){
                location.reload();
            }
        }
    }catch{}
};