General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
javascript site exceptions not working
Posted by: Mello
Date: November 26, 2017 02:58AM

I have javascript globally disabled, it saves considerably on bandwidth when using a pay-as-you-go dongle, but non of the individual sites I allow in K-m 76RC javascript settings are functioning with javascript.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Yogi
Date: November 26, 2017 10:35AM

I've never used "Permissions" before, tested now with KM 76RC2 now and can confirm your problem.
As far as I can see global settings if set to block are overwriting the "allow" setting in "Permissions".

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: JohnHell
Date: November 26, 2017 05:05PM

Quote
Mello
I have javascript globally disabled, it saves considerably on bandwidth when using a pay-as-you-go dongle, but non of the individual sites I allow in K-m 76RC javascript settings are functioning with javascript.

The whitelist is not intended for that purpose.

When you disable JS globally, you disable JS. And disable JS is disable all JS.

The whitelist is intended, for example, when you have enabled JS, but disabled for third party scripts.

Let's say you visit example.com that relays on third party hosting (CDNs, APIs, etc) for scripts, like bootstrap and google analytics.

Let's imagine that you want to load the bootstrap scripts, otherwise the site looses functionality, but not the google analytics. So, you don't want to enable third party scripts or all would load.

You'll then add maxcdn.bootstrapcdn.com to the JS permissions whitelist and example.com will load the bootstrap scripts without need to enable all third party.

But JS must be enabled, but for site only.


The opposite, blacklisting, is when you let all sources scripts, but want to block some third party.


The all JS, or only site JS scripts are controlled by the preference: permissions.default.script, set to 3, only site; set to 1, to allow all.

http://kb.mozillazine.org/Permissions.default.image (even though this page talks about image permissions, the script permissions preference has the same behaviour)



Edited 2 time(s). Last edit at 11/26/2017 05:07PM by JohnHell.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: JohnHell
Date: November 26, 2017 05:15PM

You can use ExExceptions to control them:
http://kmeleonbrowser.org/forum/read.php?9,124407


Or maybe you find interesting this thread as well. Ended with a YesScript working extension.
http://kmeleonbrowser.org/forum/read.php?1,138148

YesScript
http://kmeleonbrowser.org/forum/read.php?9,138259



Edited 1 time(s). Last edit at 11/26/2017 05:17PM by JohnHell.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Yogi
Date: November 26, 2017 05:43PM

@JohnHell

I didn't knew myself what those permissions are exactly good for. smiling smiley

For someone (like me) who was used to Opera Presto (where you could make per-site permissions regardless of the global status) Mozilla's permissions are quite tricky.
However, for some reason I always preferred to toggle and to block annoying connections with a third party tool.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Mello
Date: November 26, 2017 06:15PM

Thank you.

Not having much luck so far. ExExceptions loads a blank window when I access
it's permissions page and YesScript has a disable javascript blacklist.
I need to whitelist a few sites.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: JohnHell
Date: November 26, 2017 06:19PM

I did a quite comprehensive explanation of how works in K-meleon (and therefore Mozilla) from 75.0beta3.

From the second link above:
http://kmeleonbrowser.org/forum/read.php?1,138148#msg-138158

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: JohnHell
Date: November 26, 2017 06:21PM

Not even the latest, Mello?

I had to admit I don't even use myself (I'm a do it manually guy):
http://kmeleonbrowser.org/forum/read.php?9,124407#msg-142716

Anyway, have in mind that whitelist, without JS, is impossible.



Edited 2 time(s). Last edit at 11/26/2017 06:22PM by JohnHell.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Mello
Date: November 26, 2017 08:04PM

I find this complicated John

Yes I have latest ExExceptions

I'm going to reinstall K-m and begin over, this k-m has gotten flaky, now youtube is showing a blank page with or without js.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Mello
Date: November 26, 2017 11:32PM

"Anyway, have in mind that whitelist, without JS, is impossible".

Why is this on k-m?
It is easy on theworld chrome and MAxthon

Guess the easiest solution is to right click and send page to another js enabled browser.



Edited 1 time(s). Last edit at 11/26/2017 11:35PM by Mello.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: JohnHell
Date: November 26, 2017 11:34PM

Quote
Mello
"Anyway, have in mind that whitelist, without JS, is impossible".

Why is this on k-m?
It is easy on theworld chrome and MAxthon

It is not in K-meleon, it is how it works in Gecko, the engine by Mozilla, so happens as well in Firefox.


You can't have globally disabled JS and pretend to have it working for a site.

It's not a K-meleon fault, it is a Gecko design.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Mello
Date: November 27, 2017 12:27AM

Thanks,

Sending page to another browse is working well, I'm wondering if it wouldn't be too complex to create a toolbar button for this instead of the three steps required for the right click dialogue

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: JohnHell
Date: November 27, 2017 12:41AM

You have to forgive me here, but as I don't use 76.0 I can't guide much, but a button in toolbars.cfg 76 (with the new skin system) is:

button name{
macros(the macro that call the new browser)
Description
}

You'll need to change the highlighted and add to your skin's toolbars.cfg.

Or you could do it by macros, but maybe that is... a way more complex.

Or wait for someone that uses that version



Anyway, forgetting the above, can't you just toggle JS when needed (F2)? Disabled always but enabled when you open the page. Or is it a page that is doing something in the background and JS can't be disabled?



Edited 1 time(s). Last edit at 11/27/2017 12:41AM by JohnHell.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: rodocop
Date: November 27, 2017 01:55AM

There is also an option to toggle JS only for page viewed.

One should only activate corresponding button on Privacy bar in toolbars.cfg:
#	!JavaScript Page{
#	pageToggleJS|&Privacy
#	Block JavaScript on the current page.
#	check.png[0,32,32]
#	}
deleting # signs to get
	!JavaScript Page{
	pageToggleJS|&Privacy
	Block JavaScript on the current page.
	check.png[0,32,32]
	}


Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Mello
Date: November 28, 2017 05:38PM

Well, after trying your code John, I now have a toolbar listed for opening other browser but no button.
I tried typing in the name of an image I placed in the skin but it doesn't show


As for toggling js there is no toolbars.cfg in default skin folder

js toggle on/off does not auto refresh so it would be easier to open page in another quick loading browser from a button click.



Edited 1 time(s). Last edit at 11/28/2017 05:38PM by Mello.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: JohnHell
Date: November 28, 2017 06:09PM

Quote
Mello
Well, after trying your code John, I now have a toolbar listed for opening other browser but no button.
I tried typing in the name of an image I placed in the skin but it doesn't show

You'll need to edit skin.cfg and... well, this might be complicated..., or follow by rodocop. He is using the latest version, not me, or better said, he uses the new skinning system. I'm using the old for certain incompatibilities with my OS.

A guide for JSON files and how the new skin.cfg works (that is a JSON file format) can be understood with this image:

http://kmeleonbrowser.org/forum/read.php?8,131009,131237#msg-131237

Quote
Mello
As for toggling js there is no toolbars.cfg in default skin folder

Sorry, yes, the default toolbars.cfg is at K-Meleon root folder\browser\defaults\settings. If you use your own skin, instead, is in the folder of that skin. Usually you want your own toolbars.cfg for a new skin.

Instead modify that file, you can copy that file to Default skin folder... and modify there.

Quote
Mello
js toggle on/off does not auto refresh so it would be easier to open page in another quick loading browser from a button click.

And that has a reason. Firefox can't stop JS execution on a page. K-meleon can. And can, of course, "resume it" (enable it again) without a page reload. So add a refresh after toggle may be not the best in some cases.


Really, please, read this to understand how a page / script behaves depending on JS on load of a page.
http://kmeleonbrowser.org/forum/read.php?1,138148#msg-138158



Edited 1 time(s). Last edit at 11/28/2017 06:12PM by JohnHell.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Mello
Date: November 28, 2017 11:40PM

Info appreciated, I've a lot to catch up on.

I did a cheat and went for a keyboard shortcut instead of a button by editing the ie.kmm.

This is a bodgers guide, lol (I'm sending page to TheWorld browser)

I'd already downloaded and edited a chromium.kmm extension and searched and replaced all chromium entries with "TheWorld" (browser) It worked

Then I noticed there was an existing CTRL ALT I shortcut to send a page to ie
so I edited the ie.kmm replacing IE entries with "TheWorld" and changed the shortcut to something easier - CTRL M

Next I text searched the K_M installation folder for CTRL ALT I using AGent
Ransack and discover it in the commands.html (browser\defaults) and changed that also to CTRL M

But it didn't work unless TheWorld.kmm was also edited to CTRL M


Haven't a clue how it works but it does.

Options: ReplyQuote
Re: javascript site exceptions not working / Howto: buttons by macro
Posted by: siria
Date: November 29, 2017 12:21AM

Quote
Mello
Haven't a clue how it works but it does.

grinning smiley grinning smiley

Have a little button test for you, if you like.
Prob is, it's using the "modern" button commands, so cannot currently test myself (old computer), and no clue if it works or not. It's a macro, would recommend to copy the text after the end of the file sendto.kmm and rename it to sendto_mod.kmm
But first make sure you have an icon pic for IE in your skins/shared folder, name it "ie.png" or otherwise change the lines below as you prefer.
Also make sure your ie.kmm macro is back to original again, because this is for the test button.

Creating a toolbar and button by macro (in KM76 or younger):

_SendToBrowser_BuildToolbar {
addtoolbar("SendToBrowser") ;
addbutton("SendToBrowser", "macros(IE_OpenPage)", $_SendTo_Page, "Open page in Internet Explorer. Right-click for menu");
setcmdicon("macros(IE_OpenPage)", "ie.png");

# TEST LATER:  addbutton("SendToBrowser", "macros(WorldBrowser_OpenPage)", $_SendTo_Page, "Open page in World Browser. Right-click for menu");

# TEST LATER:  setcmdicon("macros(WorldBrowser_OpenPage)", "WorldBrowser.png");

}
$OnSetup=$OnSetup."_SendToBrowser_BuildToolbar;";

(_HOWTO_ create a button in toolbar)



Edited 3 time(s). Last edit at 07/08/2018 07:41PM by siria.

Options: ReplyQuote
Re: javascript site exceptions not working
Posted by: Mello
Date: November 29, 2017 10:29PM

That's neat siria

Button appears on toolbar and opens Internet Explorer

Options: ReplyQuote
Re: javascript site exceptions not working / toolbar buttons
Posted by: siria
Date: November 29, 2017 11:03PM

It does? Cool grinning smiley Thanks for testing!
Guess with this example you can now customize and create similar buttons easily, any way you wish. Forgot to mention, it also shows a right-click menu.

But that external solution is probably not really necessary, perhaps also consider testing the native PageToggleJS-button?
Edit > Configuration > Toolbars
and then simply remove a few comment # signs, as rodocop described already.
Then again... you are aware it will appear on the Privacy Bar?? Prob is, out-of-box it's probably hidden again. If hidden, toggle it on by right-clicking on a free space in the toolbar (not bookmarks bar). Or by menu: View > Toolbars > Privacy Bar

Quote
rodocop
There is also an option to toggle JS only for page viewed.
One should only activate corresponding button on Privacy bar in toolbars.cfg:
#	!JavaScript Page{
#	pageToggleJS|&Privacy
#	Block JavaScript on the current page.
#	check.png[0,32,32]
#	}
deleting # signs to get
	!JavaScript Page{
	pageToggleJS|&Privacy
	Block JavaScript on the current page.
	check.png[0,32,32]
	}

PS: if those buttons are far too broad, you can make them much smaller by shortening their names in the first button line, before the {
For example "!JavaScript Page" to "!JS Page". Those names have no function, can be shortened to anything.
But inside 1 toolbar ALL button names must be short enough, because the longest one defines the width for all in the same toolbar.



Edited 2 time(s). Last edit at 11/29/2017 11:18PM by siria.

Options: ReplyQuote
Re: javascript site exceptions not working / toolbar buttons
Posted by: Mello
Date: November 30, 2017 11:50PM

Thanks again siria, I'll play around with it at the weekend.

Options: ReplyQuote
Re: javascript site exceptions not working [HOWTO]
Posted by: siria
Date: December 02, 2017 02:28AM

(_HOWTO_ domain exceptions permissions javascript)

Regarding permissions and especially whitelists, Mozilla has it all BACKWARDS - a pure nightmare, a complicated mess, obviously trying to make whitelisting JS as useless as possible, grrr sad smiley And so convoluted and confusing, every time I try to dig into it and get this nonsense into my head, soon keep forgetting it again. Now, yet another try again, after studying again Johns explanations here:
http://kmeleonbrowser.org/forum/read.php?1,138148#msg-138158
and considering how exceptions work in my own daily use, in an older KM-version.

No solution, just to sum up my current understanding, for anyone interested (no guarantee for correctness):

- the GLOBAL settings do work as expected: Block all / allow all / block 3rd-party
- but the EXCEPTIONS work backwards!!
Not target, but source matters.

Black/Whitelisting for example images on "counter.com", does NOT mean ON that domain (in urlbar), but FROM that domain - EVERYWHERE!
(okay, bad example, counters usually need JS+Frames, even 10x more complicated)

Better example: https://mobile.twitter.com
BLACKLIST "mobile.twitter.com": images=Deny or Site (no 3rd party)
=> useless, user thumbnails (hosted on pbs.twimg.com) still showing
BLACKLIST "pbs.twimg.com": images=Deny or Site
=> NOW the user thumbnails on "mobile.twitter.com" (and whole web) are gone!

Same for "subdocuments" (frames, iframes):
BLACKLIST "example.com": subdocuments=Deny or Site
=> useless, counter in iframe (hosted elsewhere) is still showing, and other frames too
BLACKLIST "counter.com": subdocuments=Deny or Site
=> NOW the counter frames on "example.com" (and whole web) are gone!

Same for script permissions etc.
Not the target domain matters for exceptions, only the source domain.

ATTENTION iframes!!
If you have GLOBALLY blocked "3rd party" stuff, but have SUBDOCUMENTS ALL allowed, then other domains inside frames/iFrames can still run "their own" stuff inside "their own frame"! (for example those tiny omnipresent FB, twitter, etc. iframes)
Test page:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe
(for example show in the frame the KM-forum, and block GLOBALLY 3rd party stylesheets => the KM-frame will load the KM-style)

JAVASCRIPT exceptions
Now the nightmare is even multiplied, because there are not just 1, but several prefs involved!!
1) global: javascript.enabled = true/false
=> Blocks ALL script stuff+files. If blocked, end of story, no exceptions, the other pref is dead too. Absolute priority.
2) global: default.permission.scripts = allow / site / block
This pref is only for linked script FILES, which are imported with a source-tag. It can NOT block inline script lines or DOM-events like "onload" or "onclick" etc.
http://kb.mozillazine.org/Hostperm.1#script (ignore the obsolete hostperm, find nothing newer, but sure still same exception definition)
If script FILES are blocked by THIS global pref, exceptions can be whitelisted!
BUT: pref-1 must be allowed, that means inline-script lines etc. must run everywhere.

Notes:
if js-files files are blocked, those inline-scripts cannot open them either, as tested by John last year. And also exceptions definitely work only "from" a domain, not "for" a domain.
Little JS Test Page for mixing prefs 1+2, it calls a local js-FILE. Really works only if BOTH prefs are allowed. The file-pref must either be globally allowed or this domain whitelisted (if works, shows alert box)
http://xahlee.info/js/ex/js_unicode.html

Ah yes, and very important for exception handling too:
google.com is NOT a domain!
Weird but true, "google.com" is not treated like a domain, like e.g. "example.com". Instead, it's merely considered by the servers like a double country code of the sort "co.uk".
That means, unlike all other (normal) sites, you cannot catch all subdomains of xyz.google.com at once. The only chance is to list every subdomain individually, because for the machines only the "xyz" part is considered as main domain. That's also why listing just google in a host file doesn't work to catch everything from it.
Have found that explanation for this curiosity awhile ago on some expert site, probably stackoverflow. They wrote they find it very strange too, but obviously someone with the power to define those country lists deliberately wanted it this way.

CONCLUSION:
Exceptions (for everything except scripts) are fine only in the few cases when you know their SOURCE domain.
If you want to globally block 3rd-party stuff, that block is rather useless unless you globally block 3rd-party "subdocuments" too (frames/iframes)
Without additional ADDONS it is NOT possible to block javascript completely and whitelist any exceptions. Also not possible to allow JS globally and blacklist a domain FULLY. Inline scripts and events will still run on that domain.

If some of the above is nonsense please tell smiling smiley
(And in a few days I will have this sick convoluted system forgotten yet again...)

-----------
unsure, newer KM-versions:
KM-command "navToggleJS": toggles pref "javascript.enabled", global default for all windows and tabs.
KM-command "pageToggleJS":
not sure what this does exactly, and how long valid?? Set domain exception (or URL)? Source exception (or target)? for session? for one page-load? permanently? What about frames on current URL?
And what does this exactly?
http://kmeleonbrowser.org/forum/read.php?1,143316,143389#msg-143389

-----------
My personal choice:
That stuff is just too complicated!! And I prefer to have the current settings clearly visible in the toolbars anyway. Want and need as much as possible blocked by default, JS, media objects, DOMstore etc. Subdocuments are globally restricted to domain-only (locks out the omnipresent Facebook etc. iframes tracking you on just about ALL websites nowadays). Exceptions are quickly set with great addon ExExceptions, mostly for blacklisted stuff. For whitelisting I prefer to just toggle global settings back and forth on the very few sites where needed, then (re)loading only those single pages. No prob, and the toolbars always show the current setting. Long live the Privacy Bar, with more extra buttons!! And also my macros Blockeria (multi-toggle with 1 click) and Priv3buttons (triple toggle for 3rd-party), those buttons were long since worn out too if they were physical grinning smiley

-----------
Suggestion for a lightly bothersome workaround if anyone needs JS often, and has no addon for it:
Perhaps try working with two independant, parallel sessions, in 2 windows. One has JS blocked, the other allowed. Both must use different profile folders. KM can be set to ask at startup which of several profiles shall be started (Edit > Manage Profiles > Ask). The commandline for starting parallel sessions needs a parameter " -new" added at the end (e.g. desktop link with "c:/programs/K-Meleon76/kmeleon.exe -new")



Edited 6 time(s). Last edit at 07/08/2018 07:38PM by siria.

Options: ReplyQuote
Re: javascript site exceptions not working / toolbar buttons
Posted by: rodocop
Date: December 02, 2017 02:30AM

Great tutorial on buttons, siria!

I've already written the same in russian somewhere in Runet ;-)



Edited 1 time(s). Last edit at 12/02/2017 02:31AM by rodocop.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.