2022-01-06 21:52:32 -05:00
// ==UserScript==
// @name Bypass Twitter Sensitive
// @namespace https://bubbletea.dev/
2022-01-20 18:43:30 -05:00
// @version 2.2
2022-01-20 18:32:45 -05:00
// @description Bypasses Twitter's "Caution: This profile may include potentially sensitive content" page and "The following media includes potentially sensitive content" warnings.
2022-01-06 21:52:32 -05:00
// @author shibao
2022-01-20 18:43:30 -05:00
// @include /^https://twitter.com.*$/
// @include /^https://mobile.twitter.com.*$/
2022-01-06 21:52:32 -05:00
// @downloadURL https://gitea.bubbletea.dev/shibao/bypass-twitter-sensitive/raw/branch/stable/bypass-twitter-sensitive.user.js
// @updateURL https://gitea.bubbletea.dev/shibao/bypass-twitter-sensitive/raw/branch/stable/bypass-twitter-sensitive.user.js
// @grant none
// ==/UserScript==
// from https://developer.mozilla.org/en-US/docs/Web/API/Node#recurse_through_child_nodes
function eachNode ( rootNode , callback ) {
if ( ! callback ) {
const nodes = [ ]
eachNode ( rootNode , function ( node ) {
nodes . push ( node )
} )
return nodes
}
if ( false === callback ( rootNode ) ) {
return false
}
if ( rootNode . hasChildNodes ( ) ) {
const nodes = rootNode . childNodes
for ( let i = 0 , l = nodes . length ; i < l ; ++ i ) {
if ( false === eachNode ( nodes [ i ] , callback ) ) {
return
}
}
}
}
( function ( ) {
'use strict' ;
const observer = new MutationObserver ( function ( mutationList ) {
for ( const mutation of mutationList ) {
for ( const addedNode of mutation . addedNodes ) {
// recurses through all child nodes as well
eachNode ( addedNode , function ( node ) {
2022-01-20 18:32:45 -05:00
if ( node . nodeName == 'SPAN' && ( node . innerHTML == 'Yes, view profile' || node . innerHTML == 'View' ) ) {
2022-01-06 21:52:32 -05:00
const viewProfileBtn = node . closest ( "div[role='button']" ) ;
if ( viewProfileBtn ) { viewProfileBtn . click ( ) ; }
}
} ) ;
}
} ;
} ) ;
observer . observe ( document , {
childList : true ,
subtree : true ,
attributes : true ,
attributeFilter : [ "role" ]
} ) ;
} ) ( ) ;