mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-11-04 09:13:00 +00:00 
			
		
		
		
	Remove pbj=1 parameter from YouYube urls in recaptcha activity
This commit is contained in:
		@@ -53,6 +53,16 @@ public class ReCaptchaActivity extends AppCompatActivity {
 | 
			
		||||
    public static final String YT_URL = "https://www.youtube.com";
 | 
			
		||||
    public static final String RECAPTCHA_COOKIES_KEY = "recaptcha_cookies";
 | 
			
		||||
 | 
			
		||||
    public static String sanitizeRecaptchaUrl(@Nullable final String url) {
 | 
			
		||||
        if (url == null || url.trim().isEmpty()) {
 | 
			
		||||
            return YT_URL; // YouTube is the most likely service to have thrown a recaptcha
 | 
			
		||||
        } else {
 | 
			
		||||
            // remove "pbj=1" parameter from YouYube urls, as it makes the page JSON and not HTML
 | 
			
		||||
            return url.replace("&pbj=1", "").replace("pbj=1&", "").replace("?pbj=1", "");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private WebView webView;
 | 
			
		||||
    private String foundCookies = "";
 | 
			
		||||
 | 
			
		||||
@@ -64,15 +74,10 @@ public class ReCaptchaActivity extends AppCompatActivity {
 | 
			
		||||
        final Toolbar toolbar = findViewById(R.id.toolbar);
 | 
			
		||||
        setSupportActionBar(toolbar);
 | 
			
		||||
 | 
			
		||||
        String url = getIntent().getStringExtra(RECAPTCHA_URL_EXTRA);
 | 
			
		||||
        if (url == null || url.isEmpty()) {
 | 
			
		||||
            url = YT_URL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        final String url = sanitizeRecaptchaUrl(getIntent().getStringExtra(RECAPTCHA_URL_EXTRA));
 | 
			
		||||
        // set return to Cancel by default
 | 
			
		||||
        setResult(RESULT_CANCELED);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        webView = findViewById(R.id.reCaptchaWebView);
 | 
			
		||||
 | 
			
		||||
        // enable Javascript
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user