0

I am running Safari, on a Mac with OSX El Capitan and I want a way to permanently remove an element from every webpage in a domain.

I do not want a temporarily make changes. I would like my answer to work in Safari, I have to say this twice because stupid editors and other users are continuing to point me to un-applicable solutions for firefox here.

i.e. https://www.google.com/search?num=100&client=safari&rls=en&q=test&oq=test still has the same element blocked as https://www.google.com/

I am aware of extensions that do it for Firefox - "Remove It Permanently" and "Yet Another Remove It Permanently" - but is there any way to do this in Safari, or would an extension have to be made to accomplish this task?

Whitecat
  • 569

1 Answers1

1

One way to do it is use an extension that allows scripts to be added to a webpage.

I used the extension Quickscript for Safari. I created the following script to run and delete by classname every time I open the webpage:

removeElementsByClass('<className to delete>');

function removeElementsByClass(className){
    var elements = document.getElementsByClassName(className);
    while(elements.length > 0){
        elements[0].parentNode.removeChild(elements[0]);
    }
}

Another way is to delete by item id.

removeElementsById('<id to delete>');

function removeElementsById(id){
    var elements = document.getElementById(id);
    while(elements.length > 0){
        elements[0].parentNode.removeChild(elements[0]);
    }
}

This can also be accomplished by creating a function using jquery.

removeElementsById('#<id to delete>');
removeElementsByClass('.<className to delete>');

function removeElementsByClass(className){
    $(className).remove();
}
function removeElementsById(id){
    $(id).remove();
}

Note: This solution is browser and OS independent. It only requires you find an extension that allows you to run scripts on websites.

Custom JavaScript for websites will work with chrome.

Whitecat
  • 569