Javascript Tampermonkey and Captcha - javascript

This is my first post so don't be too hard on me.
I've made a script for Tampermonkey to do some tasks on a specific website. However, sometimes the captcha code appears and stop my script. It's a simple captcha, not images. So I thought about making another script to click on captcha and then merge the two of them.
Here is what I made so far for captcha
(function() {
'use strict';
setTimeout(function() { document.getElementsByClassName("recaptcha-checkbox-checkmark")[0].click(); }, 1000)})();
It works fine on https://patrickhlauke.github.io/recaptcha/ , here I tested it but on my website, it doesn't work.
Someone told me something like
"It works if you yourself interact with the site because then it
"activates" the box But if you do nothing and just let the script do
its thing, it doesn't/shouldn't work It's loaded on another document,
so it's inaccessible through the document object If it was that easy
to click the box, no one would use recaptcha - its existence is solely
based on being unclickable by simple JS scripts"
I didn't fully understand this. Is there any way I can make it work?

Related

Hotlinks in JavaScript

I've been developing graphics in a graphics editor and I was able to add hot links to navigate through to different graphics, by entering the pathway to the graphic file. However there is now a new version of editor makes you publish the graphics online and view them from the web and the hotlink option is replaced with a button option. Instead of being able to enter the pathway of the graphic file I want to link to I have to enter a JavaScript script, that will run on click, and I have no clue how to get the JavaScript to work like the hotlink was working.
I have looked up tutorials on JavaScript but cant get any of the code to work on my button even simple things like alerts and prompts. If anyone has any idea how to these buttons work or if its possible for them to behave like the hotlinks from before that would be great.
Well it largely depends on your software, which you didn't mention here. However, if in the end it will be displayed in browser, you can try something like this:
For link, use javascript: alert('test'); and see if that gives you an alert box when you click it. If it does, problem solved.
If not, I am affraid you'll have to provide more information about your software before someone can offer some advice.

Missing elements (Facebook Like button) when using Ajax pagination

I'm trying to help a good friend out with his site. I did not make this site so I'm diving into the deep, I am also new with WP. He wants a new audio player and Ajax pagination.
So far I did everything manually. It's a rough start though. I just load the next page with Ajax and fetch a div from that page.
My problem is: all posts contain a Facebook Like button and a Tweet button at the bottom. Now when I load the next page of posts (the div), those buttons disappear. I guess it has to do with plugins that are being loaded when the page itself is loaded. It is also missing the number of comments. These are Facebook comments also. To be honest I have no idea how to fix this...
Edit: Ok, I'm pretty sure I somehow need to reload that plugin in the Javascript chain... is that possible?
You can check it out at
Is there a better way? Am I actually doing it right? Is there a plugin that makes this easier? Again, I did not make this site and it's my first time using WP. I have no idea where to find the page settings (which might contain the max posts per page etc.)
Thanks in advance, I hope I am clear, if not, please say.
What you need to do is refresh the Facebook plugins after loading dynamic content with Ajax. Here's a snippet of code I used on a project:
// Run this on your Ajax callback
try{
// This code reloads the Facebook plugins
FB.XFBML.parse();
}
catch(ex){
// Something went wrong
}
The code requires you to load the Facebook API (duh!).

JQuery Mobile: <script> tags do not show up but code runs

I'll refer to this ticket as step in the right direction for what I need:
jQuery mobile not loading new page scripts
One of the answers states that any code NOT nested in the first $([data-role=page]) tag in jQuery mobile will NOT show up in the html. I don't know if maybe this is a browser quirk or not but regardless, the code IS getting run despite it NEVER showing up. I find this difficult if I want to debug the js code since I can't add break points to any of it.
I've also had a problem with using the Jquery autocomplete plugin as it only works ONE time and then after submitting the form and returning the the form it no longer works. I believe this is because the page (well a partial piece of it by jquery mobile) gets reloaded and the autocomplete plugin is no longer bound to my textbox. I've tried using the live and on methods to make sure they get rebound but this doesn't work.
Can any javascript/jquery mobile geniuses out there help me out with this problem? Thanks!

How do I run a script after internal scripts are fully loaded?

I'm trying to hide specific people in the Facebook sidebar chat list.
My first attempt was to just try and replace the name of a user in the chat bar but a simple .replace doesn't work since the chat bar loads separately, and long after the page itself has loaded.
Is there any way of running the Greasemonkey script after the chat has loaded?
I've heard some about the unsafeWindow functionality, but I'm not sure if I can apply that here, and if so, how.
unsafeWindow.hidePerson = function() {
document.body.innerHTML = document.body.innerHTML.replace(/Firstname Lastname/g, '' );
}
unsafeWindow.hidePerson();
To answer the question about "Running scripts after internal scripts are fully loaded", see this answer (the question scenario is the same as an AJAX scenario).
However, several things in your case:
Your issue, "I'm trying to hide specific people in the Facebook sidebar chat list", is already covered by Facebook!
See "Can I turn chat on for just a few friends?"
Follow the instructions there, and you can:
Hide just the people you specify
Or, show only the people you designate
Or, turn chat off completely
Don't attempt to set innerHTML like that; you'll bust the page (Event listeners will get trashed, etc.).
unsafeWindow is a non issue here, and is not needed.
If you mean something that I haven't covered, see this page, this page, and this page.
Then edit your question (or ask a new one), and include, at a minimum, the HTML snippet of the part of chat you want to affect, and screenshots of the same.

Pagination with special loading function?

I was searching for a script or at least a code snippet but haven't really made any progress. Anyway, I'm looking for a script that works like a simple pagination javascript but it should be accessible by linking from anywhere in the document and by calling it with the URL (e.g. on www.abc.de/default.html#thirddiv the third page of the pagination is displayed). Further, the contents should be loaded upon request (when the user clicks on the link and enters the specific page of the pagination), so that cookies, that have been set or deleted in the same document earlier can be used later without reloading the entire page. Something like that is used on Facebook for calling contents and loading them.
I've found a script on CSS Tricks called BetterBlogroll but I don't really get my mind into this. A pagination script from DynamicDrive is already working very well on the page but my problem is that there should be running three of them on the same page and as I said, the content should be loaded upon the user's request.
The script I'd need does not has to be with loads of CSS, the best way would be plain javascript and only the required CSS and HTML data. Anything else just disturbs. If anyone can help me out here, I'd be very thankful.
Check out Ryan Bates's Railscasts #174 and #175. These two are not rails specific, and explain this well.

Categories

Resources