Stop WebGadget accessing the internet

Just starting out? Need help? Post your questions and find answers here.
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Stop WebGadget accessing the internet

Post by ricardo »

firace wrote:I investigated a little bit more.
The hanging is caused by the CSS file, which unfortunately does not seem to obey DLCTL directives.
In your example page the file is named bundle.css.
A quick hack to disable the loading of the CSS file is to rename it to a different filename (eg, disabledbundle.css)
Then the page always loads instantly in my tests.

(If you'd prefer to preserve most styles in that file, there's another quick hack which I'm still testing at the moment)
Id the problem is the CSS file, the solution is Meyer's CSS reset (vert well know) or any other CSS reset:

Code: Select all

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
  margin:0;
  padding:0;
  border:0;
  outline:0;
  font-size:100%;
  vertical-align:baseline;
  background:transparent;
}

body {
  line-height:1;
}

article,aside,details,figcaption,figure,
footer,header,hgroup,menu,nav,section { 
  display:block;
}

nav ul {
  list-style:none;
}

blockquote, q {
  quotes:none;
}

blockquote:before, blockquote:after,
q:before, q:after {
  content:'';
  content:none;
}

a {
  margin:0;
  padding:0;
  font-size:100%;
  vertical-align:baseline;
  background:transparent;
}

/* change colours to suit your needs */

ins {
  background-color:#ff9;
  color:#000;
  text-decoration:none;
}

/* change colours to suit your needs */

mark {
  background-color:#ff9;
  color:#000; 
  font-style:italic;
  font-weight:bold;
}

del {
  text-decoration: line-through;
}

abbr[title], dfn[title] {
  border-bottom:1px dotted;
  cursor:help;
}

table {
  border-collapse:collapse;
  border-spacing:0;
}

/* change border colour to suit your needs */
hr {
  display:block;
  height:1px;
  border:0;   
  border-top:1px solid #cccccc;
  margin:1em 0;
  padding:0;
}

input, select {
  vertical-align:middle;
}

ARGENTINA WORLD CHAMPION
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Stop WebGadget accessing the internet

Post by ricardo »

BarryG wrote:ricardo, how do I call that? I tried this which (obviously) doesn't work. I know nothing about proxies.

Code: Select all

SetProxy1("",0,0)

You need a proxy, in the exmaple i put just an imaginary number, you need to put your own

Code: Select all

SetProxy1("152.98.42.35", "8080")
ARGENTINA WORLD CHAMPION
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Stop WebGadget accessing the internet

Post by BarryG »

IdeasVacuum wrote:String Size - I see, it is actually an IDE limit but the error message does not suggest that!
"Bug" report done for you -> viewtopic.php?f=4&t=75611
fluent
User
User
Posts: 68
Joined: Sun Jan 24, 2021 10:57 am

Re: Stop WebGadget accessing the internet

Post by fluent »

In case someone still has a need for this, calling the following procedure (InitOfflineWebGadget) works fine for me:

Code: Select all


Procedure InitOfflineWebGadget()  
  Structure S1 
    mode.i
    *pNextHop
    *pStub
  EndStructure
    
  owg.S1
  owg\mode      = 3  
  owg\pNextHop  = @"0"
  
  CallFunctionFast(GetFunctionEntry(OpenLibrary(-1,"urlmon"), 241), 38, @owg, SizeOf(S1), 0) 
EndProcedure


;;; Testing

OpenWindow(0, 0, 0, 800, 600, "OFFLINE_WG") 

InitOfflineWebGadget() 
WebGadget(0, 10, 10, 780, 580, "C:\testfile.html")    

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 

BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Stop WebGadget accessing the internet

Post by BarryG »

fluent wrote: Mon May 17, 2021 3:23 pmthe following procedure (InitOfflineWebGadget) works fine for me
Just saw this, and tried it with high hopes, but it doesn't work here. The WebGadget still hangs for over a minute while trying to load external resources with my test HTML file. Thanks for trying to help!

Image
firace
Addict
Addict
Posts: 902
Joined: Wed Nov 09, 2011 8:58 am

Re: Stop WebGadget accessing the internet

Post by firace »

Just a shot in the dark: try replacing

owg\pNextHop = @"0"

With one of the below:

owg\pNextHop = Ascii("00.00")

or

owg\pNextHop = Ascii("FE80::1")

or

owg\pNextHop = ascii(“localsystem”)
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Stop WebGadget accessing the internet

Post by BarryG »

Tried all 3 with no luck, firace. I'll do some searching with StackOverflow again later.
firace
Addict
Addict
Posts: 902
Joined: Wed Nov 09, 2011 8:58 am

Re: Stop WebGadget accessing the internet

Post by firace »

BarryG wrote: Mon Jun 28, 2021 9:49 pm Tried all 3 with no luck, firace. I'll do some searching with StackOverflow again later.
Question: Do you need images and links to be active? If you are OK with no links/images, I may have a solution suitable for you (part of a feature I am building for my web browser)
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Stop WebGadget accessing the internet

Post by BarryG »

firace wrote: Wed Jun 30, 2021 12:13 pmDo you need images and links to be active? If you are OK with no links/images, I may have a solution suitable for you (part of a feature I am building for my web browser)
Hi again firace. No, all I want is the HTML with no external links followed; see here -> viewtopic.php?p=556007#p556007

So if the HTML code is loading local files, that's okay, but not for loading external images/data from the net. Thanks.
firace
Addict
Addict
Posts: 902
Joined: Wed Nov 09, 2011 8:58 am

Re: Stop WebGadget accessing the internet

Post by firace »

You may want to give the latest version of Nessie (my toy, PB-based web browser) a try - specifically with the -offline command-line argument:

Code: Select all

nessie.exe -offline yourHTMLfile.html
Nessie homepage: https://www.radsix.com/

Does this offline mode match your requirements ?

Note that the browser source code is not currently available, but I can see if it's feasible to easily extract the offline viewing code.
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Stop WebGadget accessing the internet

Post by BarryG »

firace wrote: Wed Jun 30, 2021 1:42 pmDoes this offline mode match your requirements ?
Yes, it does! Finally! Haha. It loads and shows the basic HTML without trying to load external resources from their links, as if my network was disabled.

I would very much appreciate it if you could post the relevant code that works the magic - I'm so curious to see what does the job. Thanks!
firace
Addict
Addict
Posts: 902
Joined: Wed Nov 09, 2011 8:58 am

Re: Stop WebGadget accessing the internet

Post by firace »

BarryG wrote: Wed Jun 30, 2021 9:47 pm
firace wrote: Wed Jun 30, 2021 1:42 pmDoes this offline mode match your requirements ?
Yes, it does! Finally! Haha. It loads and shows the basic HTML without trying to load external resources from their links, as if my network was disabled.

I would very much appreciate it if you could post the relevant code that works the magic - I'm so curious to see what does the job. Thanks!
Great news! I'll send you a PM shortly.
acreis
Enthusiast
Enthusiast
Posts: 182
Joined: Fri Jun 01, 2012 12:20 am

Re: Stop WebGadget accessing the internet

Post by acreis »

Good day purebasic-ers fellows!

Is it possible share the code for offline webbrowsing?

Thanks in advance!
firace
Addict
Addict
Posts: 902
Joined: Wed Nov 09, 2011 8:58 am

Re: Stop WebGadget accessing the internet

Post by firace »

acreis wrote: Fri Jul 02, 2021 1:04 pm Good day purebasic-ers fellows!

Is it possible share the code for offline webbrowsing?

Thanks in advance!
Give this one a try.
Depending on your exact needs, it could be sufficient.
Post Reply