2022-01-29 20:50:44 +01:00
import React from 'react' ;
2022-01-17 19:50:14 +01:00
import ReactDOM from 'react-dom' ;
2022-04-13 11:44:59 +02:00
import Options from '../../options' ;
2022-01-17 19:50:14 +01:00
import { StolenData } from './stolen-data' ;
2022-04-13 11:44:59 +02:00
import { getshorthost , useEmitter } from '../../util' ;
import { getMemory } from '../../memory' ;
2021-10-03 09:03:56 +02:00
async function getCurrentTab() {
2022-01-17 19:50:14 +01:00
const [ tab ] = await browser . tabs . query ( {
active : true ,
windowId : browser.windows.WINDOW_ID_CURRENT ,
} ) ;
return tab ;
2021-10-03 09:03:56 +02:00
}
2022-04-13 11:44:59 +02:00
import './../../styles/global.scss' ;
2022-01-17 19:50:14 +01:00
import './sidebar.scss' ;
2021-10-03 09:03:56 +02:00
const Sidebar = ( ) = > {
2022-04-15 10:34:29 +02:00
const url = new URL ( document . location . toString ( ) ) ;
const origin = url . searchParams . get ( 'origin' ) ;
2022-01-29 21:20:25 +01:00
const [ minValueLength , setMinValueLength ] = React . useState < number | null > (
localStorage . getItem ( 'minValueLength' ) === null
? 7
: ( localStorage . getItem ( 'minValueLength' ) as unknown as number )
) ;
const [ cookiesOnly , setCookiesOnly ] = React . useState < boolean > ( false ) ;
const [ stolenDataView , setStolenDataView ] = React . useState < boolean > ( true ) ;
2022-02-02 10:33:09 +01:00
const [ cookiesOrOriginOnly , setCookiesOrOriginOnly ] = React . useState < boolean > ( false ) ;
2022-02-07 15:28:01 +01:00
const [ eventCounts , setEventCounts ] = useEmitter ( getMemory ( ) ) ;
2022-02-02 10:33:09 +01:00
const [ marksOccurrence , setMarksOccurrence ] = React . useState < boolean > ( false ) ;
2022-05-02 13:46:53 +02:00
const [ infoDataDialogAck , setInfoDataDialogAck ] = React . useState < boolean > (
localStorage . getItem ( 'infoDataDialogAck' ) === null
? true
: localStorage . getItem ( 'infoDataDialogAck' ) == 'true'
? true
: false
) ;
2022-02-02 10:33:09 +01:00
const [ warningDataDialogAck , setWarningDataDialogAck ] = React . useState < boolean > (
localStorage . getItem ( 'warningDataDialogAck' ) === null
? true
: localStorage . getItem ( 'warningDataDialogAck' ) == 'true'
? true
: false
) ;
2022-04-15 13:58:29 +02:00
const [ detailsVisibility , setDetailsVisibility ] = React . useState < boolean > (
localStorage . getItem ( 'detailsVisibility' ) === null
2022-01-29 21:20:25 +01:00
? false
2022-04-15 13:58:29 +02:00
: localStorage . getItem ( 'detailsVisibility' ) == 'true'
2022-01-29 21:20:25 +01:00
? true
: false
) ;
2021-11-06 21:48:25 +01:00
2022-01-29 21:20:25 +01:00
React . useEffect ( ( ) = > {
2022-02-02 10:33:09 +01:00
for ( const cluster of Object . values ( getMemory ( ) . getClustersForOrigin ( origin ) ) ) {
2022-01-29 21:20:25 +01:00
if ( cluster . hasMarks ( ) ) {
return setMarksOccurrence ( true ) ;
2022-01-19 14:12:52 +01:00
}
2022-01-29 21:20:25 +01:00
}
2022-04-11 13:52:45 +02:00
2022-01-29 21:20:25 +01:00
return setMarksOccurrence ( false ) ;
2022-04-15 10:34:29 +02:00
} , [ eventCounts [ '*' ] ] ) ;
2022-01-19 14:12:52 +01:00
2022-01-29 21:20:25 +01:00
return (
< div className = "sidebar" >
2022-04-15 13:58:29 +02:00
< header className = "header" >
< img src = "../../assets/icon-addon.svg" height = { 32 } > < / img >
< div className = "webpage-metadata" >
2022-01-29 21:20:25 +01:00
{ origin ? (
< >
< span > Analiza strony < / span >
2022-02-02 10:33:09 +01:00
< span className = "webpage-metadata--hyperlink" > { origin } < / span >
2022-01-29 21:20:25 +01:00
< / >
2022-01-29 21:16:53 +01:00
) : (
2022-01-29 21:20:25 +01:00
< span > Przejdź do wybranej strony internetowej < / span >
2022-01-29 21:16:53 +01:00
) }
2022-01-29 21:20:25 +01:00
< / div >
2022-04-24 22:11:33 +02:00
< button
className = "button button--report"
onClick = { ( ) = > {
window . open (
` /components/report-window/report-window.html?origin= ${ origin } ` ,
2022-05-22 17:29:10 +02:00
'new_tab'
2022-04-24 22:11:33 +02:00
) ;
} }
>
Generuj raport
< / button >
2022-01-29 21:20:25 +01:00
< / header >
2022-01-29 21:16:53 +01:00
2022-01-29 21:20:25 +01:00
{ stolenDataView ? (
< nav >
< button
onClick = { ( ) = > {
2022-07-06 19:32:09 +02:00
window . open (
` /components/report-window/report-window.html?origin= ${ origin } ` ,
'new_tab'
) ;
2022-01-29 21:20:25 +01:00
} }
>
2022-07-06 19:32:09 +02:00
< img src = "/assets/icons/report.svg" width = "20" height = "20" / >
< span > Generuj raport < / span >
2022-01-29 21:20:25 +01:00
< / button >
< button
onClick = { ( ) = > {
2022-04-15 13:58:29 +02:00
setDetailsVisibility ( ! detailsVisibility ) ;
2022-01-29 21:20:25 +01:00
} }
>
2022-04-15 13:58:29 +02:00
< img
src = {
detailsVisibility
? '/assets/icons/file_minus.svg'
: '/assets/icons/file_find.svg'
}
2022-01-29 21:20:25 +01:00
width = "20"
height = "20"
2022-04-15 13:58:29 +02:00
/ >
2022-02-02 10:33:09 +01:00
2022-04-15 13:58:29 +02:00
< span >
{ detailsVisibility ? 'Ukryj szczegóły' : 'Wyświetlaj szczegóły' }
< / span >
< / button >
2022-07-06 19:32:09 +02:00
< button onClick = { ( ) = > setStolenDataView ( ! stolenDataView ) } >
< img src = "/assets/icons/settings.svg" width = "20" height = "20" / >
< span > Ustawienia < / span >
< / button >
2022-04-24 22:11:33 +02:00
{ localStorage . getItem ( 'blottingBrowser' ) ===
'nikttakniesplamitwojejprzeglądarkijakspidersweb' ? (
< button
onClick = { ( ) = > {
if (
window . confirm (
'Czy chcesz wczytać wszystkie domeny w celu „splamienia” twojej przeglądarki? Uwaga przeglądarka może zablokować otwieranie nowych kart. (Ten krok jest opcjonalny)'
2022-04-15 13:58:29 +02:00
)
2022-04-24 22:11:33 +02:00
) {
let deep_copy = JSON . parse (
JSON . stringify (
Object . values (
getMemory ( ) . getClustersForOrigin ( origin )
) . map ( ( domain ) = > domain . id )
)
2022-04-15 13:58:29 +02:00
) ;
2022-04-24 22:11:33 +02:00
for ( const domain of deep_copy ) {
window . open ( ` https:// ${ domain } ` ) ;
}
2022-04-15 13:58:29 +02:00
}
2022-04-24 22:11:33 +02:00
} }
>
< img src = "/assets/icons/bulb.svg" width = "20" height = "20" / >
< span > Odwiedź wszystkie domeny < / span >
< / button >
) : null }
2022-01-29 21:20:25 +01:00
< / nav >
) : null }
< section >
{ stolenDataView ? (
< >
2022-05-02 13:46:53 +02:00
{ infoDataDialogAck ? (
< section className = "dialog-container dialog-container--info" >
< span >
2022-07-06 18:50:35 +02:00
< strong >
Rentgen automatycznie zaznacza wybrane domeny na podstawie
zebranych danych .
< / strong > { ' ' }
Możesz teraz przejść do generowania raportu lub dokonać korekty .
2022-05-02 13:46:53 +02:00
< / span >
< button
onClick = { ( ) = > {
setInfoDataDialogAck ( false ) ;
localStorage . setItem (
'infoDataDialogAck' ,
false as unknown as string
) ;
} }
>
< img src = "/assets/icons/close_big.svg" width = "16" height = "16" / >
< / button >
< / section >
) : null }
2022-01-29 21:20:25 +01:00
{ warningDataDialogAck ? (
2022-05-02 13:46:53 +02:00
< section className = "dialog-container dialog-container--warning" >
2022-01-29 21:20:25 +01:00
< span >
2022-07-06 18:50:35 +02:00
< strong > Uwaga ! < / strong > Niekoniecznie każda przesłana poniżej
2022-05-02 13:46:53 +02:00
informacja jest daną osobową . Niektóre z podanych domen mogą
należeć do właściciela strony i nie reprezentować podmiotów
2022-02-02 10:33:09 +01:00
trzecich .
2022-01-29 21:20:25 +01:00
< / span >
< button
onClick = { ( ) = > {
setWarningDataDialogAck ( false ) ;
localStorage . setItem (
'warningDataDialogAck' ,
false as unknown as string
) ;
} }
>
2022-02-02 10:33:09 +01:00
< img src = "/assets/icons/close_big.svg" width = "16" height = "16" / >
2022-01-29 21:20:25 +01:00
< / button >
< / section >
) : null }
< StolenData
origin = { origin }
2022-02-07 15:28:01 +01:00
eventCounts = { eventCounts }
2022-01-23 21:42:49 +01:00
minValueLength = { minValueLength }
cookiesOnly = { cookiesOnly }
cookiesOrOriginOnly = { cookiesOrOriginOnly }
2022-04-15 13:58:29 +02:00
detailsVisibility = { detailsVisibility }
2022-01-23 21:42:49 +01:00
/ >
2022-01-29 21:20:25 +01:00
< / >
) : (
< Options
minValueLength = { minValueLength }
setMinValueLength = { setMinValueLength }
cookiesOnly = { cookiesOnly }
setCookiesOnly = { setCookiesOnly }
cookiesOrOriginOnly = { cookiesOrOriginOnly }
setCookiesOrOriginOnly = { setCookiesOrOriginOnly }
warningDataDialogAck = { warningDataDialogAck }
setWarningDataDialogAck = { setWarningDataDialogAck }
2022-04-15 13:58:29 +02:00
detailsVisibility = { detailsVisibility }
setDetailsVisibility = { setDetailsVisibility }
2022-04-24 22:11:33 +02:00
setStolenDataView = { setStolenDataView }
2022-07-06 19:32:09 +02:00
removeCookies = { ( ) = > {
getMemory ( ) . removeCookiesFor ( origin ) ;
getMemory ( ) . emit ( 'change' , origin ) ;
setMarksOccurrence ( false ) ;
} }
removeRequests = { ( ) = > {
getMemory ( ) . removeRequestsFor ( origin ) ;
getMemory ( ) . emit ( 'change' , origin ) ;
setMarksOccurrence ( false ) ;
} }
2022-01-29 21:20:25 +01:00
/ >
) }
< / section >
< / div >
) ;
2021-10-03 09:03:56 +02:00
} ;
2022-01-29 21:20:25 +01:00
2022-01-17 19:50:14 +01:00
ReactDOM . render ( < Sidebar / > , document . getElementById ( 'app' ) ) ;