Mayayana
2017-07-12 12:14:04 UTC
** Posted in VBS group from a HOSTS file
discussion in Win10 group. **
"Auric__" <***@email.address> wrote
| Mayayana wrote:
|
| > I have a VBS file I keep on my Desktop. When I
| > visit a page that I think may have new muck I
| > download the webpage, drop it on the script, which
| > then parses the page for URLs and shows me a
| > list. I can select any on the list to be added to
| > both HOSTS files, cancel, and/or add other URLs.
|
| Would you be willing to post that script over in
| microsoft.public.scripting.vbscript ?
|
http://www.jsware.net/jsware/browsertips.php5#host
The download there (hosts.zip) is a package designed
to provide a basic primer about HOSTS files for people
concerned about privacy.
There are two versions, one for IE and one for other
browsers. The "iebut" subfolder has scripts and icons.
I wrote this some time ago. I don't know which version
of IE breaks it. Probably 11, which breaks IE-specific
functions. But I don't really know. It also predates IE
tabs, assuming there's just one actual browser window
of the IE variety running.
The IE package takes advantage of the ability to
add a custom button to the IE toolbar that then links to
a script. When you click the button, the script uses
Shell.Application to get the collection of Explorer/IE
windows, finds an IE instance, gets the document
content, and parses that. So it's a one-click approach.
If you wanted to use that I guess you might need
to edit the code to step down into the browser window
collection. I don't remember exactly how it works now.
I think the actual IE browser windows are embedded
inside windows of class IEFrame or some such. And I
don't know how the ShellApp.Windows collection deals
with that. But I suppose very few people care about
HOSTS and also use IE these days, anyway.
The CollectURLs script is for use with other browsers,
or any webpage. Use File -> SaveAs to get the webpage.
Drop the HTML file onto the script. It gets parsed to find
URLs. It's not perfect and could probably be improved.
The code just looks for ".com", ".net", etc. Many pages
now are mostly obfuscated javascript and sleazy
URLs are often obfuscated, assembled by script rather
than written in the page HTML. The script won't catch those.
It can still be handy, though; a lot easier than trying to
read the source code.
After parsing the page content it pops up a window
with a list of URLs found. The list can be edited, aded to,
or even just used to add a new URL instead of editing
HOSTS by hand.
I added Acrylic HOSTS to my version. For anyone with
experience scripting that would be easy to do. Around
line 160-ish the script adds the new URLs to HOSTS.
The same code can be repeated to do the same for
Acrylic HOSTS.
A final caveat: As has been touched on in this thread,
later versions of Windows can be a pain in the neck with
file restrictions. If you don't turn off UAC you can't drop
files onto VBS because there's no way to elevate. Also,
many AV programs now monitor HOSTS and may complain
or block editing. Maybe something like Lionel's approach
of clearing restrictions via BAT file first would work. I've
never tried that.
discussion in Win10 group. **
"Auric__" <***@email.address> wrote
| Mayayana wrote:
|
| > I have a VBS file I keep on my Desktop. When I
| > visit a page that I think may have new muck I
| > download the webpage, drop it on the script, which
| > then parses the page for URLs and shows me a
| > list. I can select any on the list to be added to
| > both HOSTS files, cancel, and/or add other URLs.
|
| Would you be willing to post that script over in
| microsoft.public.scripting.vbscript ?
|
http://www.jsware.net/jsware/browsertips.php5#host
The download there (hosts.zip) is a package designed
to provide a basic primer about HOSTS files for people
concerned about privacy.
There are two versions, one for IE and one for other
browsers. The "iebut" subfolder has scripts and icons.
I wrote this some time ago. I don't know which version
of IE breaks it. Probably 11, which breaks IE-specific
functions. But I don't really know. It also predates IE
tabs, assuming there's just one actual browser window
of the IE variety running.
The IE package takes advantage of the ability to
add a custom button to the IE toolbar that then links to
a script. When you click the button, the script uses
Shell.Application to get the collection of Explorer/IE
windows, finds an IE instance, gets the document
content, and parses that. So it's a one-click approach.
If you wanted to use that I guess you might need
to edit the code to step down into the browser window
collection. I don't remember exactly how it works now.
I think the actual IE browser windows are embedded
inside windows of class IEFrame or some such. And I
don't know how the ShellApp.Windows collection deals
with that. But I suppose very few people care about
HOSTS and also use IE these days, anyway.
The CollectURLs script is for use with other browsers,
or any webpage. Use File -> SaveAs to get the webpage.
Drop the HTML file onto the script. It gets parsed to find
URLs. It's not perfect and could probably be improved.
The code just looks for ".com", ".net", etc. Many pages
now are mostly obfuscated javascript and sleazy
URLs are often obfuscated, assembled by script rather
than written in the page HTML. The script won't catch those.
It can still be handy, though; a lot easier than trying to
read the source code.
After parsing the page content it pops up a window
with a list of URLs found. The list can be edited, aded to,
or even just used to add a new URL instead of editing
HOSTS by hand.
I added Acrylic HOSTS to my version. For anyone with
experience scripting that would be easy to do. Around
line 160-ish the script adds the new URLs to HOSTS.
The same code can be repeated to do the same for
Acrylic HOSTS.
A final caveat: As has been touched on in this thread,
later versions of Windows can be a pain in the neck with
file restrictions. If you don't turn off UAC you can't drop
files onto VBS because there's no way to elevate. Also,
many AV programs now monitor HOSTS and may complain
or block editing. Maybe something like Lionel's approach
of clearing restrictions via BAT file first would work. I've
never tried that.