How can i fetch youtube webpage source code using android studio - javascript

i am creating an app to read tags form youtube videos but when i try to download web page using AsyncTask it showing an error like
</script>
05-21 01:18:37.829 12067-12067/com.improfessional.j.tagfetcher I/System.out: <noscript>
05-21 01:18:37.829 12067-12067/com.improfessional.j.tagfetcher I/System.out: براہ کرم اپنے براؤزر پر جاوا اسکرپٹ فعال کریں۔
05-21 01:18:37.829 12067-12067/com.improfessional.j.tagfetcher I/System.out: </noscript>
05-21 01:18:37.829 12067-12067/com.improfessional.j.tagfetcher I/System.out: </html>
which means to enable java script...
And is there a way to download webpage code faster cause AsyncTask is taking noticeable long time.
Thank-you

Problem is related with youtube web site. Pages can't be downloaded without browser (javascript). May be you need to use webview ( hidden ) to load page
Check How do I get the web page contents from a WebView?

Related

Block javascript disabled users from wordpress site

I am having a huge problem. I need to prevent access to non javascript users for a page on my website. I am not very technical when it comes to websites, hmtl or java ect. But I have a page that i would like non javascript users to not be able to access. I have tried lots of code from here in my header and footer such as
<noscript>
<meta http-equiv="refresh" content="0; URL=nojs/index.php">
</noscript>
but it does not work.
To put this into more detail my problem is that a host a webpage with a list of download links. There is an app (web browser) for amazon devices (android) that accesses webpages and allows you to download but it comes with javascript disabled by default.
This means that my Ads dont show and i am now getting 40TB a month bandwidth usage from people using this software which means i may have to pull the site soon as it costs more to run than the ads give back.
I think i need to either block non javascript users. Or is there a way i can make my links on that page in javascript so that none javascript users cant see or use them?
In an ideal world i would just like to display a message saying please enable javascript in settings but i have tried many header codes with no success. Any help here greatly appreciated
I tried using the meta tag inside the noscript tags like you did, and it worked fine for me. Try using an absolute link to your nojs page instead of the relative one you have. I don't know of a way to completely block nonjs users. Another option would be to use the noscript tags to hide the content of your html pages when js is disabled. This won't completely disable nonjs users from seeing your pages since if they are tech-savy they could use inspect-element to unhide the page content, but for the most part it should do a good job of preventing nonjs users from viewing your page. You can also include a no script alert. For example:
<!DOCTYPE html>
<html>
<head>
<title>
</title>
<noscript>
<style>
div.content {
display: none;
}
</style>
</noscript>
</head>
<body>
<noscript>
Please enable Javascript to view this Page
</noscript>
<div class=content>
Page Content Here
</div>
</body>
</html>

YouTube video wants to download instead of load via jQuery

In short, mobile browsers try to download a random file instead of loading video into the main player Website.
More info:
I've built a webseries type site on WordPress, that uses jQuery to load a video into the main player: http://suzellediy.com/
Recently, I made it responsive - and now, when testing on mobile, when clicking on the video thumbnail, the video does not want to load into the main player.
Instead of loading the video, mobile Chrome and Safari wants to download the file instead. The issue cannot be recreated by using firebug / chrome mobile emulator.
Any ideas what the issue could be?
Actually you may be able to reproduce the issue on the desktop when you disable Flash.
Try changing the URL in:
jQuery("#mainplayer").attr("src", "http://youtube.com/v/WKmUqV7abgw"+
"?&autoplay=1&loop=1&listType=user_uploads&list=suzellediy");
To this:
jQuery("#mainplayer").attr("src",
"https://www.youtube.com/embed/WKmUqV7abgw" +
"?autoplay=1&loop=1&listType=user_uploads&list=suzellediy");
Or this:
jQuery("#mainplayer").attr("src",
"https://www.youtube.com/embed/WKmUqV7abgw" +
"?autoplay=1&loop=1&listType=user_uploads&list=suzellediy&html5=1");
and see if that works.
Most likely what you see is that mobile browsers that don't support Flash try to download a file if they can't play it.

Javascript/DOM not detecting new HTML

I'm working on a private Chrome extension that injects some code into specific websites. I am successful for all except THIS 1 website (which I cant provide you with login access, sorry).
My extension doesn't detect the new(most) of the html content being loaded on the page after navigating through the site only.
For example, when I run document.documentElement.innerHTML; the return string is only the barebones of the page.
The site is using JQuery and I do have JQuery also loaded in my extension, but it still doesn't want to read any elements. The elements do show up in Developer Console but NOT on the Source Page or Frame's Source Page
I really need access to those Elements but I can't figure it out.
Any help is appreciated.
Thanks a bunch.
EDIT: Turns out nothing was working because all the new content was being loaded into an iFrame. Now I have to research iframes :(
This is what the code in the developer's tools looks like
<html>
<iframe src="..." >
#document
<html>
<div id="im trying to get">this content</div>
</html>
</iframe>
</html>

using window.location.href to point to javascript enabled page

I am creating a personal website.So,its a very lightweight website!
The website uses jquery heavily.So if target browser doesn't have javascript enabled,my website would not work.
To resolve this issue I used this html
<html>
<head>
<script>
window.location.href="javascriptEnabled.html";
/*Since javascript is enabled redirect to javascript based page*/
</script>
</head>
<body>
Showing Static Website since javascript is not enabled..
</body>
</html>
As you can see,I am redirecting to javascript enabled page if the target browser supports it.
But if javascript is not enabled,the script would not work and then static html would be loaded which is in body tag!
I have two questions.
1>Is this the best way to resolve javacript-no javascript issue browser issue?
2>If I use window.location.href and the browser is javascript enabled,would it download the full page or would it stop at window.location.href?
To keep things simple, yes it's an OK idea. You can load content with <noscript> tags
As soon as the browser hits that window.location.href it will start redirecting, but it will still download all DOM. Browsers download all Document then it will start to render.
You can use: <body onload="document.body.style.display = 'none';"> to hide it's contents until redirect occurs.

adding an iframe to facebook does not work anymore since ~2 weeks

I'm writing a firefox extension to read out the privacy settings of a facebook user. (not a facebook app!!) To switch between different websites of facebook I used iframes, but this isn't working anymore. I have this problem since 2 weeks.
$('#globalContainer').append('<iframe id="reusable_iframe" src="" width="90%"
height="400" name="reusable_iframe"></iframe>');
//....
$('#reusable_iframe').attr('src', link);
I'm follow the Same origin policy and it was working just fine since a 2 weeks!? an example:
var link = "http://www.facebook.com/editprofile.php?sk=basic";
Now I just get a blank iframe :(
the funny thing is, that if I add "http://www.youtube.com/embed/Qi_AAqi0RZM" or "http://trololololololololololo.com/" to the iframe it's working without a problem... :/
did facebook change the rules for own links in iframes? Is there a workaround? Is there an other way for me to scan different sites with firefox-extensions? i would prefer to stay with content-scripts....
Edit: This is how it looks at firebugs... also funny is that the facebook page http://www.facebook.com/undefined is working however!?
<iframe id="areusable_iframe" width="90%" height="400" name="areusable_iframe" src="http://www.facebook.com/">
<html>
<head>
</head>
<body>
</body>
</html>
</iframe>
Facebook sends the following response header to the browser:
X-Frame-Options: DENY
This cause all major browsers (even IE8 and higher) to prevent showing it inside frames.
The old way was "frame buster" using JavaScript forcing the page to open as the top window, but it's very unfriendly so it was replaced by this header in most modern websites that don't want to be displayed in frames.
Not much you can do though, sorry.
The "undefined" page is just blank content which is their 404 custom error page as it does not contain the above header, it can be displayed inside frame.
To learn more about the X-Frame-Options header see this documentation.

Categories

Resources