General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Javascript Whitlist
Posted by: Trisha
Date: December 01, 2017 11:02AM

Hello!
I want to disable Javascript in general. Pages where I allow JS are listed under "Permissions".
Nevertheless, JS is not executed on these pages.
What am I doing wrong?

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: Yogi
Date: December 01, 2017 11:46AM

Please read this thread.

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: Trisha
Date: December 01, 2017 12:19PM

Thanks Yogi,

I want to run visitor exchange services.
For example, if I now call http://hitssurfer.com/hits.php?id=3844, are scripts only executed by hitssurfer. com?
Alternatively, is there an addon like Noscript for Firefox?

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: Trisha
Date: December 01, 2017 12:42PM

It seems to work like this!
I have tested it, I have a page with 2 frames loaded on my server.
JS in the frame is not executed by external pages!

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: Trisha
Date: December 01, 2017 12:56PM

Now I have found a page where code is executed from other sites:
http://marianawagner.de/index.php/astro-news/
Normally only scripts should be executed on marinawagner.de.
The nice yellow counters are on http://live-counter.com and should be deactivated.
Or did I misunderstand something?

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: Trisha
Date: December 02, 2017 04:41PM

So it is impossible to allow JS only on certain websites?

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: JohnHell
Date: December 02, 2017 04:54PM

Quote
Trisha
So it is impossible to allow JS only on certain websites?

No, if you disable it globally.

Consider it as a car engine. You can't switch on the Air-Conditioner (AC) system without start the engine first.

But, you can do the opposite. You can start the engine, but you can switch off the AC.

Anyway, as Yogi told, read that thread, or better, this post, where I explain how it works
http://kmeleonbrowser.org/forum/read.php?1,138148#msg-138158


And what you told here is confusing.

Quote
Trisha
It seems to work like this!
I have tested it, I have a page with 2 frames loaded on my server.
JS in the frame is not executed by external pages!

Quote
Trisha
Now I have found a page where code is executed from other sites:
http://marianawagner.de/index.php/astro-news/
Normally only scripts should be executed on marinawagner.de.
The nice yellow counters are on http://live-counter.com and should be deactivated.
Or did I misunderstand something?



Maybe what you are searching for is allow javascript for a site, but block some third party. That can be done with the mix of the preference told in the link above and whitelisting or blacklisting as explained.

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: adodupan
Date: December 03, 2017 03:16AM

Quote
Trisha
So it is impossible to allow JS only on certain websites?

Yes, it is possible.
In past, i've added a few lines to km and it works fine. I prefer to block javascript just on several websites, but same code will do the job for you.
Go to about:config and check if there exist pref 'permissions.default.script'. If not, you need to add a new INT pref, then set the value to 2.
Global javascript must be enabled.

Paste this code into the error console and make some tests:
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://gre/modules/Services.jsm');
const TEST = {
  observe: function(aSubject, aTopic, aData) {
    if (aTopic == 'content-document-global-created') {
      var ALLOW_ACTION = 1, DENY_ACTION = 2, permission = Services.perms.testPermission(aSubject.document.documentURIObject, 'script'),
      doc = aSubject.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
        .getInterface(Components.interfaces.nsIWebNavigation)
        .QueryInterface(Components.interfaces.nsIDocShell);
      if ((Services.prefs.getIntPref('permissions.default.script') == DENY_ACTION && permission != ALLOW_ACTION) ||
        !Services.prefs.getBoolPref('javascript.enabled') || permission == DENY_ACTION)
        doc.allowJavascript = false;
      else
        doc.allowJavascript = true;
    }
  },
  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver, Components.interfaces.nsISupportsWeakReference])
};
Services.obs.addObserver(TEST, 'content-document-global-created', true);
If you need something like this, you or someone can put this code in an addon.

Best regards to all

Options: ReplyQuote
Re: Javascript Whitlist
Posted by: Trisha
Date: December 03, 2017 06:32AM

Hello, thank you!
You two have helped me a lot, it works now!!

Options: ReplyQuote


K-Meleon forum is powered by Phorum.