script to remove part of a webpage

surfactant
12/21/2012 02:26 am
Hi, Audry

Is it possible to find a general plugin to remove ads in a webpage?

I examined the webpage myself and found that, if I remove the content after a string "<li class='comments'>", most ads can be skipped and the stored page would be significantly smaller - one third the orginal size.

If possible, could you kindly also code the pre_save function for the job?

The webpage is:
http://www.businessweek.com/articles/2012-12-10/apples-cook-says-more-macs-will-be-born-in-the-u-dot-s-dot-a-dot

If you think this request is annoying, could you kindly send me an example doing similar stuff?

Thanks!
Andrey Filatkin
12/21/2012 02:42 am
Hi,

You can remove ads with a plugin, but it's difficult to write a general plugin. There is no a common method to recognize ads.
Any webpage is a tree in point view of browser. Tree nodes have ids or classes. You can remove nodes with specified ids/classes and ads will be removed. But each site uses his own ids/classes( Therefore general ads cleaner is impossible.
I wrote a simple plugin for businessweek.com articles -

//MPIQPlugin
//Type=PreSave
//Name=AntiAds
//Author=anfilat

function remove(nodes) {
var node;

for (i = nodes.length - 1; i >= 0; i--) {
node = nodes[i];
node.parentElement.removeChild(node);
}
}

function MP_PreSave() {
var dre1, dmn, host, classes, ids;

dre1 = new RegExp(/[^\/]+\/\/([^\/]+)(?:\/(.*))?/);
dmn = document.URL.match(dre1);
if (dmn) {
host = dmn[1].toLowerCase();
if (host == "www.businessweek.com") {
classes = '.advertisement, .banner_ad';
ids = '#google_ads, #taboola-grid-2x2, #taboola-text-links, #taboola_wrapper, #bw_mall';

remove(document.querySelectorAll(classes + ', ' + ids));
}
}
}
surfactant
12/21/2012 03:03 am
Hi, Andrey

Maybe it's worthwhile for me to learn something about Javascript.

Thanks a lot for your kindly help!
Andrey Filatkin
12/21/2012 03:11 am
It's required a lot of time. Is a best solution, you can use Chrome\Opera with AdBlock and Inquiry extensions.
surfactant
12/21/2012 06:21 am
In fact, I want to remove not only those ads but also all the irrelevant information around the article, especially the large bulk at the bottom, which significantly increases the size of stored stuff.

Anyway, thanks for your advice!
Andrey Filatkin
12/21/2012 06:41 am
You can try the Readability service http://readability.com for it
surfactant
12/21/2012 11:05 am
I woud try it. Thanks!

Merry Christmas and Happy New Year!
icfcvnol
03/01/2016 08:58 pm
20
icfcvnol
03/01/2016 08:58 pm
20
icfcvnol
03/01/2016 08:58 pm
20
icfcvnol
03/01/2016 08:58 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
jltbenmp
03/01/2016 08:59 pm
20
jltbenmp
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 08:59 pm
20
icfcvnol
03/01/2016 09:00 pm
20
jltbenmp
03/01/2016 09:00 pm
20
jltbenmp
03/01/2016 09:00 pm
1'"
jltbenmp
03/01/2016 09:00 pm
\
jltbenmp
03/01/2016 09:00 pm
1????
jltbenmp
03/01/2016 09:00 pm
@@BtN0q
jltbenmp
03/01/2016 09:00 pm
JyI=
jltbenmp
03/01/2016 09:00 pm
?'?"
icfcvnol
03/01/2016 09:00 pm
20
jltbenmp
03/01/2016 09:00 pm
?''?""
jltbenmp
03/01/2016 09:00 pm
(select convert(int,CHAR(65)))
jltbenmp
03/01/2016 09:00 pm
20
jltbenmp
03/01/2016 09:00 pm
1'"
icfcvnol
03/01/2016 09:00 pm
20
icfcvnol
03/01/2016 09:00 pm
20
icfcvnol
03/01/2016 09:00 pm
20
icfcvnol
03/01/2016 09:00 pm
20
jltbenmp
03/01/2016 09:00 pm
\
jltbenmp
03/01/2016 09:03 pm
20
jltbenmp
03/01/2016 09:03 pm
20
jltbenmp
03/01/2016 09:03 pm
20
jltbenmp
03/01/2016 09:15 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:16 pm
20
jltbenmp
03/01/2016 09:17 pm
20
jltbenmp
03/01/2016 09:17 pm
20
jltbenmp
03/01/2016 09:17 pm
20
icfcvnol
03/01/2016 09:20 pm
20
icfcvnol
03/01/2016 09:20 pm
20
icfcvnol
03/01/2016 09:20 pm
JOASIhHF
icfcvnol
03/01/2016 09:20 pm
-1 OR 2+390-390-1=0+0+0+1 --
icfcvnol
03/01/2016 09:20 pm
-1 OR 2+23-23-1=0+0+0+1
icfcvnol
03/01/2016 09:20 pm
-1' OR 2+277-277-1=0+0+0+1 --
icfcvnol
03/01/2016 09:21 pm
-1' OR 2+645-645-1=0+0+0+1 or 'kustdwLo'='
icfcvnol
03/01/2016 09:21 pm
-1" OR 2+412-412-1=0+0+0+1 --
icfcvnol
03/01/2016 09:21 pm
if(now()=sysdate(),sleep(9),0)/*'XOR(if(now()=sysdate(),sleep(9),0))OR'"XOR(if(now()=sysdate(),sleep(9),0))OR"*/
icfcvnol
03/01/2016 09:21 pm
(select(0)from(select(sleep(3)))v)/*'+(select(0)from(select(sleep(3)))v)+'"+(select(0)from(select(sleep(3)))v)+"*/
icfcvnol
03/01/2016 09:21 pm
-1; waitfor delay '0:0:3' --
icfcvnol
03/01/2016 09:21 pm
-1); waitfor delay '0:0:6' --
icfcvnol
03/01/2016 09:21 pm
-1)); waitfor delay '0:0:6' --
icfcvnol
03/01/2016 09:27 pm
OZR4ygeL';select pg_sleep(9); --
icfcvnol
03/01/2016 09:27 pm
U0JuYQjt');select pg_sleep(3); --
icfcvnol
03/01/2016 09:27 pm
RCSQhvwd'));select pg_sleep(3); --
icfcvnol
03/01/2016 09:27 pm
20
icfcvnol
03/01/2016 09:27 pm
20
icfcvnol
03/01/2016 09:27 pm
yIathu18
icfcvnol
03/01/2016 09:27 pm
-1 OR 2+588-588-1=0+0+0+1 --
icfcvnol
03/01/2016 09:27 pm
-1 OR 2+820-820-1=0+0+0+1
icfcvnol
03/01/2016 09:28 pm
-1' OR 3+129-129-1=0+0+0+1 or 'zwcGVtgu'='
icfcvnol
03/01/2016 09:28 pm
-1' OR 3*2>(0+5+129-129) or 'zwcGVtgu'='
icfcvnol
03/01/2016 09:28 pm
-1" OR 2+15-15-1=0+0+0+1 --
icfcvnol
03/01/2016 09:28 pm
if(now()=sysdate(),sleep(8),0)/*'XOR(if(now()=sysdate(),sleep(8),0))OR'"XOR(if(now()=sysdate(),sleep(8),0))OR"*/
icfcvnol
03/01/2016 09:28 pm
(select(0)from(select(sleep(12)))v)/*'+(select(0)from(select(sleep(12)))v)+'"+(select(0)from(select(sleep(12)))v)+"*/
icfcvnol
03/01/2016 09:28 pm
-1; waitfor delay '0:0:12' --
icfcvnol
03/01/2016 09:28 pm
-1); waitfor delay '0:0:4' --
icfcvnol
03/01/2016 09:28 pm
-1)); waitfor delay '0:0:4' --
icfcvnol
03/01/2016 09:28 pm
1 waitfor delay '0:0:4' --
icfcvnol
03/01/2016 09:28 pm
SKuqbxux'; waitfor delay '0:0:4' --
icfcvnol
03/01/2016 09:28 pm
V90Q2T3K'); waitfor delay '0:0:8' --
icfcvnol
03/01/2016 09:28 pm
832UgDxE')); waitfor delay '0:0:12' --
icfcvnol
03/01/2016 09:28 pm
-1;select pg_sleep(12); --
icfcvnol
03/01/2016 09:28 pm
-1);select pg_sleep(12); --
icfcvnol
03/01/2016 09:28 pm
-1));select pg_sleep(4); --
icfcvnol
03/01/2016 09:28 pm
kTrsM63C';select pg_sleep(4); --
icfcvnol
03/01/2016 09:28 pm
RR41nQ9O');select pg_sleep(8); --
icfcvnol
03/01/2016 09:28 pm
UzWaYhrg'));select pg_sleep(8); --
icfcvnol
03/01/2016 09:33 pm
20
icfcvnol
03/01/2016 09:33 pm
20
NRC3APFT
03/01/2016 09:33 pm
20
-1 OR 2+939-939-1=0+0+0+1 --
03/01/2016 09:33 pm
20
-1 OR 2+538-538-1=0+0+0+1
03/01/2016 09:33 pm
20
-1' OR 2+447-447-1=0+0+0+1 --
03/01/2016 09:33 pm
20
-1' OR 2+197-197-1=0+0+0+1 or 'nUlAGbZ5'='
03/01/2016 09:33 pm
20
-1" OR 2+884-884-1=0+0+0+1 --
03/01/2016 09:33 pm
20
if(now()=sysdate(),sleep(9),0)/*'XOR(if(now()=sysdate(),sleep(9),0))OR'"XOR(if(now()=sysdate(),sleep(9),0))OR"*/
03/01/2016 09:33 pm
20
(select(0)from(select(sleep(9)))v)/*'+(select(0)from(select(sleep(9)))v)+'"+(select(0)from(select(sleep(9)))v)+"*/
03/01/2016 09:34 pm
20
1 waitfor delay '0:0:3' --
03/01/2016 09:34 pm
20
UcfIMAHI'; waitfor delay '0:0:3' --
03/01/2016 09:34 pm
20
TyfTWD7k'); waitfor delay '0:0:3' --
03/01/2016 09:34 pm
20
twBppAiE')); waitfor delay '0:0:3' --
03/01/2016 09:34 pm
20
AtkQaOsr';select pg_sleep(6); --
03/01/2016 09:34 pm
20
KeqAXaLS');select pg_sleep(6); --
03/01/2016 09:34 pm
20
TEfGFgGl'));select pg_sleep(6); --
03/01/2016 09:34 pm
20
icfcvnol
03/01/2016 09:34 pm
20
icfcvnol
03/01/2016 09:34 pm
20
NX31ikeS
03/01/2016 09:34 pm
20
-1 OR 2+468-468-1=0+0+0+1 --
03/01/2016 09:34 pm
20
-1 OR 2+297-297-1=0+0+0+1
03/01/2016 09:34 pm
20
-1' OR 2+357-357-1=0+0+0+1 --
03/01/2016 09:34 pm
20
-1' OR 2+222-222-1=0+0+0+1 or '6oiKnYxN'='
03/01/2016 09:34 pm
20
-1" OR 2+993-993-1=0+0+0+1 --
03/01/2016 09:34 pm
20
if(now()=sysdate(),sleep(8),0)/*'XOR(if(now()=sysdate(),sleep(8),0))OR'"XOR(if(now()=sysdate(),sleep(8),0))OR"*/
03/01/2016 09:34 pm
20
(select(0)from(select(sleep(8)))v)/*'+(select(0)from(select(sleep(8)))v)+'"+(select(0)from(select(sleep(8)))v)+"*/
03/01/2016 09:34 pm
20
1 waitfor delay '0:0:8' --
03/01/2016 09:34 pm
20
iQVPO1aj'; waitfor delay '0:0:12' --
03/01/2016 09:34 pm
20
ealh77Gv'); waitfor delay '0:0:12' --
03/01/2016 09:34 pm
20
bFFjVWFf')); waitfor delay '0:0:12' --
03/01/2016 09:34 pm
20
UGL3bl9m';select pg_sleep(4); --
03/01/2016 09:34 pm
20
J2ROOXPr');select pg_sleep(4); --
03/01/2016 09:34 pm
20
imZqhuC9'));select pg_sleep(8); --
03/01/2016 09:34 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:36 pm
20
icfcvnol
03/01/2016 09:43 pm
20
icfcvnol
03/01/2016 09:43 pm
20
icfcvnol
03/01/2016 09:47 pm
20
icfcvnol
03/01/2016 09:47 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:53 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:54 pm
20
icfcvnol
03/01/2016 09:58 pm
20
icfcvnol
03/01/2016 09:58 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:01 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:02 pm
20
icfcvnol
03/01/2016 10:14 pm
20
icfcvnol
03/01/2016 10:14 pm
20
icfcvnol
03/01/2016 10:14 pm
20
icfcvnol
03/01/2016 10:14 pm
20
icfcvnol
03/01/2016 10:14 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:19 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20
jltbenmp
03/02/2016 12:20 pm
20