How to close a fancybox element in Google Chrome developer tools? - javascript

I would like to close a popup content in some web pages via Chrome developer console.
For example:
When I open http://www.cw.com.tw for the first time, it will show a fancybox-content element.
So I will have to click the "close button" of the advertisement in order to read to article.
This website is trustable, but for some websites, if I don't want to click that element for some security concerns, how can I close that popup content and remove the grey layer without click the fancybox-close button.
In another word, how can I know which function it triggers when I click that fancybox-close button?
I tried inspected the element, and deleted the fancybox-contentnode directly. But it didn't help very much.
Any help would be appreciated, thanks in advance.

You should have read the document first though,
$.fancybox.close()
should do the trick.
FYI, the API documentation here.
http://fancybox.net/api

Related

Diagnosing an href value being directed to another value

I'm working on site (not designed by myself) and have run into an issue I'm not able to diagnose easily.
I have a link being generated for an author's social media profiles as such:
AuthorHandle
This is correct but when this link is clicked, there is a JQuery script (I'm assuming) running somewhere that is changing the href value to the following:
https://www.sitedomain.com/https://twitter.com/authorhandle
How would one go about running down which script was responsible for this using the Chrome DevTools?
This is obviously throwing a lot of annoying 404 errors and also not allowing site visitors to find an author's twitter page.
Sounds like Rory McCrossan's comment helped. I'll document it for anyone else in the same boat.
Right-click the element and select Inspect. Then open the Event Listeners pane and expand the click section. This shows you all of the listeners that are registered for this element's click event.

How can I trigger the click of an HTML button on a webpage?

I need to automate something.
I need to go a lot to a page, and click some buttons to download excel files (Communicatie > Exporteer ...).
I would like to just enter a link that directly executes the buttons. I don't know if this is possible.
When inspecting the source code, there is no link visible or something.
I already tried
https://mysite.be/page#communicatie_export_users_xlsx
But this doesn't work. What am I doing wrong?
Thanks in advance!
Laurent
Try using this bookmarklet:
javascript:(function() { document.querySelector("#communicatie_export_users_xlsx").click()})()
create a bookmark and paste the above into it. Then you can just click the bookmark on the page.
An alternative is to first press F12, go to network and then click the button to see what the link is they actually call. That link can be automated if they allow it. You may run into violating their TOS

How to open a link in a new tab when clicking on an image in a chrome extension?

I made a simple Chrome Extension that, when clicked, has a dropdown menu that has a row of icons. Is it possible to set it so when the icon is clicked, it opens its respective website in a new tab?
(NOTE: I have tried to make it refer to a link in the popup.html file, but if I click on the icon, it doesn't do anything.)
Any help, suggestions or advice is greatly appreciated, thanks!
You need to assign a click handler to the icon that executes the following:
chrome.tabs.create({url: websiteToOpen});
If you want it to open in the background without closing the popup, one more parameter is required:
chrome.tabs.create({url: websiteToOpen, active: false});
Do note that "tabs" permission is not needed for this.
This example from Chrome docs shows how to properly assign a click hanlder in a way that's compatible with Chrome extensions (onclick attribute will not work)
#Xan
Hey, thanks for your answer and sorry for the late reply... I figured it out though, and I didn't need to add any click handlers... I just did:
<a target = "_blank" href = "http://google.com">
<img src = "http://upload.wikimedia.org/wikipedia/commons/a/a0/Google_favicon_2012.jpg"/>
</a>
the target attribute says to open it in a new tab and it does exactly that when I click on it. Problem solved! Thanks!

Automatically click an menu button in youtube comments page using javascript

I'm trying to implement a chrome extension to retrieve comments from youtube, a problem is that I want to sort the comments by timeline,one way is to click the "Top Comments" menu and then click the "Newest First" button, I've tried many ways to simulate this operation using javascript(both in content script and chrome console) but failed. Could someone give me some hints? thanks.
Example: see comments of a youtube video here.
If you want to get the comments it's a bad idea to do it using the web interface, instead you should use the API which is less prone to changes.
Useful link:
https://developers.google.com/youtube/2.0/reference#Comments_Feeds
https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#orderbysp
https://developers.google.com/youtube/articles/changes_to_comments

Pop-up/modal dilemma

I'm stuck in a problem that on first glance seems simple, but actually it's a bit hard to fix. I have a share button on my colorbox and when a user clicks it I want to open a pop-up with the social media link. Now I tried a few simple pop-ups but a lot of the blockers are disabling them and it's not an option to force the users to disable their software.
Can anyone offer suggestions?
You can try to replace your popup with iframe integrated into your page. Place it to the center of the page, hide it initially. And on user click set iframe's src to the url which you open in popup now and show iframe.
Off the top of my head, I'd suggest some sort of modal, jqModal is pretty popular and my preferred way of doing things. Do you have any code that you could share?

Categories

Resources