I have too many Google Photos assistant's cards accumulated
How would I dismiss all those cards at once using JavaScript?
With JavaScript it's possible to do like this:
var buttons = document.getElementsByClassName("VfPpkd-Bz112c-LgbsSe material-icons-extended VxYl6");
for(var i = 0; i < buttons.length; i++)
if(buttons[i].getAttribute('aria-label') == 'Dismiss')
buttons[i].click();
Update re HOW TO APPLY THIS CODE:
Open Developer Tools (CMD+Option+I, or Menu->More Tools->Developer Tools)
Select Console tab
Paste the above code
I trying download PDF through Datatable in Safari browser but .trigger() event is not working. It working properly with chrome and mozilla firefox
Here is HTML code
Export as PDF
Java Script
$('#tablePDF').on('click', function(){
for(var i = 0; i < tables.length; i++){
var table;
table = tables[i];
table.button( '0-0' ).trigger();
}
});
where "tables" is array type of varible where i pushed datatable properties.
Kindly provide solution.
What could be the reason why the javascript function "languify" in the bottom of this page is not able to look up all the links in the topNav?
http://www.yggdrasildance.dk/
I'm writing all the links from the topNav to the console, but some are missing (for example 'about' and 'galleries').
I see that Squarespace has som additional javascript after my own. But even if I manually run the "languify" function once the page is completely loaded, the 'about' link remains unseen by the script.
Here's the relevant code:
var a_items = document.getElementById('topNav').getElementsByTagName('a');
for (var i = 0; i < a_items.length; i++)
{
console.log('inspecting link to: ' + a_items[i].getAttribute('href'));
}
I'm working on a project where I need to temporarily disable all hyperlinks, and then enable them again once my pop-up div is gone. I am able to successfully disable all the links using this function I wrote:
function disableHyperlinks(){
link_targets = Array();
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
link_targets.push(anchors[i].href);
anchors[i].href= "#";
}
}
Which also saves all the URLs so it can put them back later using this function:
function enableHyperlinks(){
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
anchors[i].href= link_targets[i];
}
}
The above code seems to work just fine, it removes all the links, and then puts them all back without any issues, however the problem is that if I run the 'enable' code after a link is clicked, its almost as if the javascript is setting the link back to the original destination and then registering the click. So despite being 'disabled' in this fashion, the link still ends up leaving the page.
The problem is demonstrated here
Click the red "L" with the white background to enable the javascript I made for selection, you'll notice anything you bring your mouse over will get a blue dashed border, I need to be able to "select" parts of the web page without redirecting to another page if a link is also clicked.. any idea how I could go about doing this properly?
(Please note I am trying to avoid JQuery)
Work on the onClick listener:
var areEnabled = false;
function toggleLinks(){
var anchors = document.getElementsByTagName('a');
for(var i=0; i < anchors.length; i++)
anchors[i].onclick = (areEnabled) ? null : function(e){ return false };
areEnabled = !areEnabled;
};
Instead of searching for many links and disabling them (which, BTW, won't help you against other clickable objects), you can create another invisible div, just below your popup on z-index that would cover entire page and catch all clicks instead of elements underneath. You can even make it semi-transparent instead of completely invisible for visual effect alerting user that "lower-level" is disabled.
I was finally able to solve my own problem by manipulating the onclick property of each hyperlink, then setting it back to what it was previously. The only problem with bokonic's response was that the onclick property was set to null to "re-enable" the link, which would then disable any javascript functionality the link had previously.
var onclickEvents;
function disableHyperlinks(){
onclickEvents = Array();
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
onclickEvents.push(anchors[i].onclick);
anchors[i].onclick=function(){return false;};
}
}
function enableHyperlinks(){
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
anchors[i].onclick = onclickEvents[i];
}
}
I would like to alter the page shown in my browser using a firefox extension (add-on) i wrote.
I am able to get the page's iframes as XPCNativeWrapper object using:
iframes = window.content.document.getElementsByTagName('iframe')
for (var i = 0; i < iframes.length; i++) {
var elmInput = iframes[i];
Firebug.Console.log(elmInput);
}
But i haven't been able to get to the iframes content, not speaking of altering it.
How can i alter the content of an iframe in the dom?
I think you want elmInput.contentDocument
for (var i = 0; i < iframes.length; i++) {
var content = iframes[i].contentWindow.document.body.innerHTML;
...
}