2023-04-02 14:09:39 +02:00
// ==UserScript==
2023-04-02 14:22:25 +02:00
// @author loviuz
2023-04-02 14:09:39 +02:00
// @name No Cookiewall Italia
// @namespace https://este.linux.it
2023-06-18 17:40:43 +02:00
// @version 1.6.0
2023-04-02 14:09:39 +02:00
// @license AGPL v3
2023-05-09 20:55:47 +02:00
// @description Permette di navigare siti web italiani di notizie evitando il cookiewall, il quale permette di accedere ai contenuti, già arrivati al browser, previa accettazione cookie o il pagamento di un abbonamento. Alcuni stabiliscono che questo comportamento dei siti non è lecito secondo il GDPR: in attesa di una pronuncia del garante della privacy propongo questo metodo per saltare questo blocco.
2023-04-02 14:09:39 +02:00
// @lang it
// ==/UserScript==
2023-05-09 20:55:47 +02:00
var cookiewall _found = false ;
2023-04-02 14:09:39 +02:00
2023-05-09 20:55:47 +02:00
var ci = setInterval ( function ( ) {
// Identifica il tipo di cookiewall
2023-06-18 17:40:43 +02:00
var is _iubenda = secureQuerySelector ( '#iubenda-cs-banner' ) || secureQuerySelector ( '#iubenda-cs-banner' ) ;
var is _privacycpwall = secureQuerySelector ( '.wall-modal' ) || secureQuerySelector ( '.privacy-cp-wall' ) ;
var is _onetrust _banner _sdk = secureQuerySelector ( '#onetrust-banner-sdk' ) ;
2023-04-02 15:26:41 +02:00
2023-05-09 20:55:47 +02:00
if ( is _iubenda ) {
2023-06-18 17:40:43 +02:00
var cookiewall _desktop = secureQuerySelector ( '.prompt-to-accept' ) ;
var cookiewall _mobile = secureQuerySelector ( '#iubenda-cs-banner' ) ;
2023-04-02 15:34:40 +02:00
2023-05-09 20:55:47 +02:00
// Cookiewall desktop
if ( cookiewall _desktop ) {
cookiewall _desktop . style . display = 'none' ;
2023-06-18 17:40:43 +02:00
secureQuerySelector ( 'html' ) . classList . remove ( 'show-prompt-to-accept' ) ;
secureQuerySelector ( '.o-wrapper.iub--active' ) . style . filter = 'none' ;
2023-05-09 20:55:47 +02:00
cookiewall _found = true ;
}
// Cookiewall mobile
if ( cookiewall _mobile ) {
2023-06-18 17:40:43 +02:00
secureQuerySelector ( '#iubenda-cs-banner.iubenda-cs-visible' ) . classList . remove ( 'iubenda-cs-visible' ) ;
2023-05-09 20:55:47 +02:00
cookiewall _mobile . setAttribute ( 'style' , 'display:none !important' ) ;
2023-06-18 17:40:43 +02:00
secureQuerySelector ( 'html' ) . setAttribute ( 'style' , '' ) ;
secureQuerySelector ( '.o-wrapper.iub--active' ) . style . blur = 'none' ;
secureQuerySelector ( '.adv-slot' ) . style . display = 'none' ;
2023-05-09 20:55:47 +02:00
cookiewall _found = true ;
}
}
2023-04-02 15:26:41 +02:00
2023-05-09 20:55:47 +02:00
else if ( is _privacycpwall ) {
2023-06-18 17:40:43 +02:00
var cookiewall _desktop = secureQuerySelector ( '.wall-modal' ) ;
var cookiewall _mobile = secureQuerySelector ( '.privacy-cp-wall' ) ;
2023-04-02 15:26:41 +02:00
2023-05-09 20:55:47 +02:00
// Cookiewall desktop
if ( cookiewall _desktop ) {
cookiewall _desktop . style . display = 'none' ;
2023-06-18 17:40:43 +02:00
secureQuerySelector ( '.tp-backdrop' ) . style . display = 'none' ;
secureQuerySelector ( 'body' ) . classList . remove ( 'tp-modal-open' ) ;
2023-05-09 20:55:47 +02:00
cookiewall _found = true ;
}
2023-04-02 16:21:23 +02:00
2023-05-09 20:55:47 +02:00
// Cookiewall mobile
if ( cookiewall _mobile ) {
cookiewall _mobile . style . display = 'none' ;
2023-06-18 17:40:43 +02:00
secureQuerySelector ( 'body' ) . classList . remove ( 'noScroll' ) ;
2023-05-09 20:55:47 +02:00
cookiewall _found = true ;
}
}
2023-04-02 16:21:23 +02:00
2023-05-09 20:55:47 +02:00
else if ( is _onetrust _banner _sdk ) {
2023-06-18 17:40:43 +02:00
var cookiewall = secureQuerySelector ( '#onetrust-banner-sdk' ) ;
2023-04-02 16:21:23 +02:00
2023-05-09 20:55:47 +02:00
// Cookiewall
if ( cookiewall ) {
cookiewall . style . position = 'absolute' ;
cookiewall . style . left = '-10000px' ;
2023-04-02 16:21:23 +02:00
2023-06-18 17:40:43 +02:00
secureQuerySelector ( '.onetrust-pc-dark-filter' ) . style . position = 'absolute' ;
secureQuerySelector ( '.onetrust-pc-dark-filter' ) . style . left = '-10000px' ;
2023-05-09 20:55:47 +02:00
2023-06-18 17:40:43 +02:00
secureQuerySelector ( 'body' ) . setAttribute ( 'style' , '' ) ;
2023-05-09 20:55:47 +02:00
cookiewall _found = true ;
}
}
if ( cookiewall _found ) {
clearInterval ( ci ) ;
}
} , 1000 ) ;
2023-06-18 17:40:43 +02:00
function secureQuerySelector ( element ) {
if ( document . querySelector ( element ) ) {
return document . querySelector ( element ) ;
} else {
return generateElements ( '<div></div>' ) ;
}
}
function generateElements ( html ) {
const template = document . createElement ( 'template' ) ;
template . innerHTML = html . trim ( ) ;
return template . content . children [ 0 ] ;
}