Improvement requests :  K-Meleon Web Browser Forum
Use this forum to talk about a feature you're missing. 
K-meleon needs the ability to fake user agent strings
Posted by: psmith
Date: April 23, 2016 03:32AM

It would be great if K-meleon could "lie" and claim to be firefox or chrome.

I am encountering more and more sites (e.g. google, gmail, facebook) which rudely and idiotically say "browser unsupported", as if there were something wrong with K-meleon. Once I get past those crappy messages, K-meleon can use all of those sites' functions just fine, the same as when I use firefox. Clearly, there's nothing wrong with K-meleon, the problem is idiots who write bad code for their sites. They write crap like "if not chrome, firefox, ie or safari, harass them with annoying messages" instead of writing standard HTML5 that works on everything. It's especially annoying when K-meleon scores as high on the HTML5 and Acid Tests as the "big" browsers.

I had the same problem with Opera 8 through 12, rude sites that said "your browser doesn't work". But Opera contained the ability to fake user agent strings. When it identified itself as Opera, websites said "unsupported" and certain features didn't work. When I made Opera pretend to be firefox, the websites worked normally. This also happened with QtWeb - fake the browser type, and no problems.

It is the same web browser and the same web site, but only the user agent string has changed. This is bad website design, not a problem with the browser. Unfortunately, the idiots doing this don't see it as their problem.



Edited 2 time(s). Last edit at 04/23/2016 08:31AM by psmith.

Options: ReplyQuote
Re: K-meleon needs the ability to fake user agent strings
Posted by: guenter
Date: April 23, 2016 10:55AM

Quote
psmith
It would be great if K-meleon could "lie" and claim to be firefox or chrome.

Spoofing Chromium or IE based browsers doesn't help.
They have a different JavaScript implementation.

Spoofing Firefox string is implemented under Tools. When on. It just adds the string Firefox to the "User Agent String".

Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Firefox/38.0 K-Meleon/38.2.0

If You need more? You can AFAIK still add the old useragent.kmm from km.1.5/1.6 times.

Save code as text file with name useragent.kmm (extension kmm not txt) and it place in ./macros

# begin code
# Begin code useragent.kmm K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- User Agent --------------------------------------------------------------------------------------------
#
# Dependencies	: main.kmm ($macroPrefBranch)
# Resources	: -
# Preferences	: kmeleon.privacy.useragent[1,2,...].name
#		  kmeleon.privacy.useragent[1,2,...].string
#
# ------------------------------------------------------------------------------------------------------------------

UserAgent{
macroinfo=_("Set the specified User Agent string");
menuchecked=$ARG==""?(getpref(STRING,$_UserAgent_Active)=="")sad smileygetpref(STRING,$_UserAgent_Active)==getpref(STRING,$_UserAgent_Custom.$ARG.".string"));
$ARG==""?delpref($_UserAgent_Active):$_string=getpref(STRING,$_UserAgent_Custom.$ARG.".string");
$ARG==""?&_UserAgent_SyncMenu:&_UserAgent;
}
UserAgent_Custom{
macroinfo=_("Set a custom User Agent string");
$_string=prompt(_("Enter the User Agent string to identify K-Meleon as:"),_("Custom User Agent"),getpref(STRING,$_UserAgent_Active));
$_string==""?0:&_UserAgent;
}

UserAgent_AlertString{
macroinfo=_("View the current User Agent string");
injectJS("alert('"._("Current User Agent String:")."\\n\\n'+navigator.userAgent)");
}
UserAgent_ToggleReset{
macroinfo=_("Toggle resetting the default User Agent string when exiting");
menuchecked=getpref(BOOL,$_UserAgent_Reset);
togglepref(BOOL,$_UserAgent_Reset);
}

# ----- PRIVATE

$_UserAgent_Active="general.useragent.override";
$_UserAgent_Custom="kmeleon.privacy.useragent";
$_UserAgent_Reset=$macroPrefBranch."useragent.reset_on_exit";

_UserAgent{
$_string==""?delpref($_UserAgent_Active):setpref(STRING,$_UserAgent_Active,$_string); &_UserAgent_SyncMenu;
}
_UserAgent_SyncMenu{
$_data=getpref(STRING,$_UserAgent_Active);
setcheck("macros(UserAgent_Custom)",($_data!=""));
$_j=1; while($_j>0) &_UserAgent_SyncMenuLoop;
}
_UserAgent_SyncMenuLoop{
$__data=getpref(STRING,$_UserAgent_Custom.$_j.".string");
$__data==$_data?setcheck("macros(UserAgent_Custom)",false):0;
$_j=$__data==""?0:$_j+1;
}
$OnStartup=$OnStartup."_UserAgent_SyncMenu;";

_UserAgent_BuildMenu{
# tools menu
$_u="&User Agent";
setmenu(PrivacySecurity,popup,$_u);
setmenu($_u,macro,"Default","UserAgent()");
$_i=1; while($_i>0) &_UserAgent_BuildMenuLoop;
setmenu($_u,macro,"&Custom...",UserAgent_Custom);
setmenu($_u,macro,"&Reset To Default On Exit",UserAgent_ToggleReset);
setmenu($_u,separator,"&Reset To Default On Exit");
}
_UserAgent_BuildMenuLoop{
$__data=getpref(STRING,$_UserAgent_Custom.$_i.".name");
$__data==""?0:setmenu($_u,macro,$__data,"UserAgent(".$_i.")");
$_i=$__data==""?0:$_i+1;
}
$OnInit=$OnInit."_UserAgent_BuildMenu;";

_UserAgent_Reset{
getpref(BOOL,$_UserAgent_Reset)?delpref($_UserAgent_Active):0;
}
$OnQuit=$OnQuit."_UserAgent_Reset;";

# ------------------------------------------------------------------------------------------------------------------
$macroModules=$macroModules."UserAgent;";

# end code

and add as ua.js to ./browser/defaults/prefernces/ua.js

This one is older You need to update the UA strings.

Insert code into text file with the extension js (not txt but js) like ua.js


// begin code
// Privacy

pref("kmeleon.privacy.useragent1.name", "75");
pref("kmeleon.privacy.useragent1.string", "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0 K-Meleon/31.2.0");
pref("kmeleon.privacy.useragent2.name", "SeaMonkey 2.3.0");
pref("kmeleon.privacy.useragent2.string", "Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0 SeaMonkey/2.30");

// end code

Can be extended. The next one would have:

pref("kmeleon.privacy.useragent3.name", "Firefox Nightly 38");
pref("kmeleon.privacy.useragent3.string", "Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Firefox/38.0");



Edited 2 time(s). Last edit at 04/23/2016 05:42PM by guenter.

Options: ReplyQuote
Re: K-meleon needs the ability to fake user agent strings
Posted by: Michael Sattler
Date: August 23, 2016 12:11PM

Hello,

I created the two files as described.

But where can I change the UA string now?

In older versions this was under settings/paranoia.


Thanks,
Michael

Options: ReplyQuote
Re: K-meleon needs the ability to fake user agent strings
Posted by: foliator
Date: August 23, 2016 02:03PM

I use a different approach; it takes a few steps, but I don't need to change the UA very often, anyway. Go to about:config (just like in Firefox) and look for the following:

general.useragent.override

If that key exists, you can open it and edit what's there. If it doesn't exist, create it as a new string value by right-clicking any of the other keys, selecting New, then String, then entering general.useragent.override into the box that appears. That will bring up another box into which you can enter your desired fake user agent string. It takes effect immediately, so you needn't restart the browser. You can check your user agent either in K-Meleon's About screen, or on a website, like this one:

https://www.whatismybrowser.com/detect/what-is-my-user-agent

Currently I'm using Mozilla/5.0 (Windows NT 6.1; rv:43.0) Gecko/20100101 Firefox/43.0.

---
Gerry

Options: ReplyQuote
Re: K-meleon needs the ability to fake user agent strings
Posted by: siria
Date: August 23, 2016 07:44PM

Too complicated for everyday use ;-)
But great for occasionally testing new strings that aren't in the menu yet.

Quote
Michael Sattler
I created the two files as described.
But where can I change the UA string now?
In older versions this was under settings/paranoia.

Is it not there anymore? Haven't checked in new version, but there used to be 3-4 ways, for different tastes.
The menu is found in TOOLS Menu (but can be copied elsewhere too).
The privbar also has a button for it, just hidden by default (unhide in toolbars.cfg, then right-click on "about" button)

Options: ReplyQuote
Re: K-meleon needs the ability to fake user agent strings
Posted by: siria
Date: August 23, 2016 08:50PM

Update for future readers:
You can now use this macro: useragents2018

http://kmeleonbrowser.org/forum/read.php?9,143898
(or the next version, useragents2019, when it's finished)

------------------------------ old post:

Can't resist, for anyone interested just a little tip for understanding macro MENUS better, because customizing them is fun and easy :cool: (Well in most cases tongue sticking out smiley This UA one is admittedly a more complicated advanced one, but most tiny macros are just unnecessarily convoluted and copied again and again in other macros without need)

So, for everything menu related just look for the "setmenu" lines in a macro kmm-file!
It tells where a new menu is found and other details:

Quote

....
_UserAgent_BuildMenu{
# tools menu
$_u="&User Agent";
setmenu(PrivacySecurity,popup,$_u);

The first name in "setmenu" is the parent menu, the last name is the new macro menu.
"popup" shows new menus as flipout menus, "inline" shows all their lines inside the parent menu.
All menu names can be named freely. Single menu lines also.

The UA example just looks a bit complicated, because "PrivacySecurity" is a submenu in Tools, it was defined in menus.cfg. The new menu could just as well be placed in "Tools" directly, but it makes sense to "sort" similar commands into submenus.

Also replacing full names with variables like "$_u" is optional, not a general requirement for all menus.
So the above could just as well be written as:

setmenu("PrivacySecurity",popup,"&User Agent");
...or placed into the top menu directly, without sorting into a submenu:
setmenu("&Tools",popup,"&User Agent");
...or with a fix line number, if you want it in a special position:
setmenu("&Tools",popup,"&User Agent",1);

...or can be added to any other menu, simply by using their name as parent menu here.
Either instead of the original place or additional to it (copy 1 line).
Important! Underlined characters must get a & before.
Or any menu name can be added to most toolbar buttons, easiest on already existing buttons on right-click (customize toolbars.cfg)



(sig) New unofficial K-Meleon 76.4 (KMG76.4) available, in own subforum.
Based on Goanna engine, called 'test' builds forever but more stable as 75.1 acc. forum members. It's 1-2 generations ahead of predecessor KM76RC-2016
K-Meleon FAQ (link missing in forum sidebar)
Tips&Tricks - Learning new stuff every day
New to K-Meleon? What do you like? What not?



Edited 3 time(s). Last edit at 07/18/2019 11:58PM by siria.

Options: ReplyQuote
Re: K-meleon needs the ability to fake user agent strings
Posted by: guenter
Date: August 23, 2016 08:51PM

Quote
siria
Too complicated for everyday use ;-)
But great for occasionally testing new strings that aren't in the menu yet.

Quote
Michael Sattler
I created the two files as described.
But where can I change the UA string now?
In older versions this was under settings/paranoia.

Is it not there anymore? Haven't checked in new version, but there used to be 3-4 ways, for different tastes.
The menu is found in TOOLS Menu (but can be copied elsewhere too).
The privbar also has a button for it, just hidden by default (unhide in toolbars.cfg, then right-click on "about" button)

It is in Tools -> User Agent after You copy the files and restart and as siria says in the Privacy Bar.

p.s. settings/paranoia is an item in Chrome and You need to hack that to get it again. I do not recommend trying to edit the chrome items to get it back.



Edited 1 time(s). Last edit at 08/23/2016 08:56PM by guenter.

Options: ReplyQuote
Re: K-meleon needs the ability to fake user agent strings
Posted by: foliator
Date: August 23, 2016 09:07PM

Quote
siria
Too complicated for everyday use ;-)
But great for occasionally testing new strings that aren't in the menu yet.

You're right, but in my case I don't change my UA on a daily basis. My current one has been in use for several months now, and so far I haven't run across any websites that ask me to use a different or updated browser. The only exception is Google's tip about switching to Chrome, which I just ignore. In fact, I don't even see that if I'm blocking Javascript.

---
Gerry

Options: ReplyQuote


K-Meleon forum is powered by Phorum.