/    Sign up×
Community /Pin to ProfileBookmark

Generate javascript errors on purpose

I would like to remove some hosting imposed google ads on my phpbb board.

Currently I accomplish this by deleting via javascript all the banners divs when the page is loaded.

But unfortunately in that way advertisements are quickly displayed before disappearing.

Now I am thinking about a different (neater) approach to my problem:

maybe I might write some javascript code which interferes with the one injected by google thus generating the inability to show those annoying divs…

Any idea?

I can’t edit html and css, I am just allowed to insert any html/javascript/css code in a separate “widget”. This is for testing purposes and I have the admin permission to try …

My current code follows

<script type=”text/javascript”>
window.onload = function(){
document.getElementById(‘ad’).getElementsByTagName(‘div’)[0].outerHTML=”;
document.getElementById(‘ad2’).outerHTML=”;
document.getElementById(‘footer’).outerHTML=”;
document.getElementById(‘ad3’).getElementsByTagName(‘a’)[1].outerHTML=”;
};
</script>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Sup3rkirbySep 25.2014 — For some reason, I get the feeling this topic somehow violates a rule somewhere... being that you are asking for help in disabling ads that your host likely requires via its terms.

Secondly, based on the title of this topic and what you seem to want to do, I can't say it's a good idea in the slightest. All hosting terms and obligations aside, you seem to want to intentionally force errors in the scripting of your page, which has never been, nor will it ever be a reasonable idea. Errors in javascript often affect more than just one thing on the page. In some cases it can cause all other scripts to simply 'stop', period. And even with the proper containment or suppression you could still be facing additional errors depending on what sort of errors you forced earlier.


Frankly, given that you can insert HTML, javascript and/or CSS, I feel like it would make much more sense to just use CSS to 'hide' any unwanted ads. Such a solution would be instant, as the styling to hide such elements would be applied as the page renders them, rather than depending on javascript to apply some sort of 'fix' after they have been loaded on to the page. The CSS you would need would of course depend on the resulting source code of the page, and so I'd need to see at least the ad portion of the page to provide you with any code.
Copy linkTweet thisAlerts:
@gnappomanauthorSep 26.2014 — Hello, thank you for your reply.

I am unsure on how to apply display:none in my situation, cause, as you can see from my code, I don't always have divs ids. In this case it is like if you got a fully loaded webpage and you are only able to add some html/css/javasctipt (or everything else).

Take this as an example

Programming and Web Development Help | DreamInCode.net (or any other google adsense site)

and try to insert (say, in the middle of body section) the display:none setting..
×

Success!

Help @gnappoman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...