Skip to content

Instantly share code, notes, and snippets.

@shunsugai
Created August 6, 2012 05:11
Show Gist options
  • Save shunsugai/3270902 to your computer and use it in GitHub Desktop.
Save shunsugai/3270902 to your computer and use it in GitHub Desktop.
removeAd
var classes = [
'plugin-free_area plugin-box',
'maist'
];
var ids = [
'ad'
];
var removeAdByClass = function(className) {
var list = document.getElementsByClassName(className);
for(var i = 0; i < list.length; i++) {
var elem = list.item(i);
elem.parentNode.removeChild(elem);
}
}
var removeAdById = function(id) {
(var elem = document.getElementById(id)).parentNode.removeChild(elem);
}
var map = function(array, method) {
for (var i = 0; i < array.length; i++) {
method(array[i]);
}
}
map(classes, removeAdByClass);
map(ids , removeAdById);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment