Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing element using imacro

First of all I am new to imacros,I am trying to remove an element from a page using imacro in a random site, for which i have tried to use the javascript which throws me an error of .remove() is not a function. Following is the piece of code which i have been trying:

var macro = "";
macro +="SET !DATASOURCE mobidomains2.csv";
macro +="SET !DATASOURCE_COLUMNS 1";
macro ="SAVEAS TYPE=PNG FOLDER=* FILE={{!COL1}}";
window.content.document.getElementsByClassName("results-explained").remove();
var ret="";
ret=iimPlay(macro);

I have also tried it with using .removechild(), so is there any way that I can delete a specific div using imacro with javascript? Thanking you in advance.

like image 941
Omkar Somji Avatar asked Sep 02 '15 13:09

Omkar Somji


People also ask

How do you delete an element?

The remove() method removes an element (or node) from the document.


1 Answers

getElementsByClassName returns a HTMLCollection. You should iterate through the set and then call the remove method on each element. Also note ChildNode.remove method is not widely-supported.

var collection = window.content.document.getElementsByClassName("results-explained");

Array.prototype.forEach.call(collection, function(node) {
    node.parentNode.removeChild(node);
});
like image 131
undefined Avatar answered Sep 21 '22 07:09

undefined