DrewNaylor / DrewWebBrowser

A lightweight web browser I'm working on based on the VB.Net Windows Forms WebBrowser control. Not in development until further notice as of January 1, 2018.
GNU General Public License v3.0
4 stars 3 forks source link

Put in a button that removes ads from pages after the page loads on-demand. #13

Open DrewNaylor opened 7 years ago

DrewNaylor commented 7 years ago

From my OneNote page on this: "In my Web Browser application, somehow put a button on the toolbar which acts as an advertisement hider using the bookmarklet code for hiding third-party iframes. Make it obvious that the button only hides ads after they are downloaded to make the page more readable and that the button is not an active adblocker (which does not allow advertisements to load.)"

JavaScript code I use provided by a page linked from a HowToGeek page:

javascript:(function(){function%20R(w){try{var%20d=w.document,j,i,t,T,N,b,r=1,C;for(j=0;t=["object","embed","applet","iframe"][j];++j){T=d.getElementsByTagName(t);for(i=T.length-1;(i+1)&&(N=T[i]);--i)if(j!=3||!R((C=N.contentWindow)?C:N.contentDocument.defaultView)){b=d.createElement("div");b.style.width=N.width;%20b.style.height=N.height;b.innerHTML="%3Cdel%3E"+(j==3?"third-party%20"+t:t)+"%3C/del%3E";N.parentNode.replaceChild(b,N);}}}catch(E){r=0}return%20r}R(self);var%20i,x;for(i=0;x=frames[i];++i)R(x)})()

The icon for this could be something like "-Ad" or maybe there could be a menuitem that's something like "BookXTensions" and the ad hider would be called "Remove ads" with a submenu for options and an "About" choice. The options I've thought of so far would be one and that's an option to run it automatically (not recommended) when pages load. It's not recommended because the ad removal code also removes elements like embedded videos from YouTube.

The tooltip text for the actual ad remover button would be something like "Remove ads from currently loaded page" and the automatically run option would have a tooltip like "Automatically remove ads as soon as pages load: Not recommended as this may cause problems with embedded videos or other wanted elements."

DrewNaylor commented 7 years ago

For the "About" information, open a small window with the ad remover icon and have the name of it on the right side, with version info below that, developer info below that, and description below that.

At the bottom is an "Ok" button to close the window.

DrewNaylor commented 7 years ago

I've found the original source of the adblock bookmarklet:

Pratyush Mittal http://fully-faltoo.com/

I can't find any code that he posted of this bookmarklet, but one site said he made a bunch of other ones in a list below and linked to his blog:

http://blogote.com/resources/google-chrome-with-firefox-addon/634/

DrewNaylor commented 7 years ago

The toolbar button could be on the status bar and would be a splitbutton with the ad hiding functionality on the left part of the button and a dropdown on the right. The dropdown would be the same submenu as the menuitem uses.

DrewNaylor commented 7 years ago

Also, maybe the adblocker information for the About window could be retrieved from an XML document to possibly allow for third-party BookXTensions/real extensions (not bookmarklets) to be made in the future.

DrewNaylor commented 7 years ago

For those who want to know, BookXTensions stands for "bookmarklet extensions." They're bookmarklets that are promoted to extensions because I don't know how to make an extension API.