browser: update wikimedia mobile browser recognition
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 4 Feb 2015 05:56:17 +0000 (06:56 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 5 Feb 2015 21:46:21 +0000 (22:46 +0100)
New tables for mobile and WAP browser versions, to count as mobile.
Caniuse distinguishes some more mobile variants.

tools/mkusage-wikimedia

index c775a4ac0333b8365f452e827f9f2972d3ee27c7..901ec15c6d39b12b47ac52c22941a931ab167a6b 100755 (executable)
@@ -3,6 +3,8 @@ use 5.010; use strict; use warnings;
 our %count;
 our $mobile;
 
+our $VERSION = '1.01';
+
 if (m{<td class=hl>} .. m{</?td>}) {
        $count{-source} = 'http://stats.wikimedia.org/archive/squid_reports/';
        $count{-title } = 'Wikimedia';
@@ -13,7 +15,7 @@ if (m{<td class=hl>} .. m{</?td>}) {
 # select relevant columns
 />Browser versions(.*)/ ... m{</table>} && last or next;
 my ($tr, $id, $count2, $count) = split /(?:<[^>]*>)+/;
-$mobile = $count2 =~ /(?<!non) mobile/ if $id ~~ '&nbsp;';
+$mobile = $count2 !~ /non mobile/ if $id ~~ '&nbsp;';
 next if $id ~~ ['Total', '&nbsp;'];
 
 # convert to usable syntax
@@ -23,11 +25,11 @@ $count =~ s/%$//;
 $version //= 0;
 given ($browser) {
        when (['Firefox', 'Iceweasel']) {
-               $browser = 'firefox';
+               $browser = $mobile ? 'and_ff' : 'firefox';
                continue;
        }
        when ('MSIE') {
-               $browser = 'ie';
+               $browser = $mobile ? 'ie_mob' : 'ie';
                continue;
        }
        when ('Opera') {
@@ -72,12 +74,18 @@ given ($browser) {
                }
        }
        when ('Chrome') {
-               $browser = 'chrome';
+               $browser = $mobile ? 'and_chr' : 'chrome';
                s/\.\d+$// for $version;
        }
        when ('Android') {
                $browser = 'android';
        }
+       when ('BlackBerry') {
+               $browser = 'bb';
+       }
+       when ('UCWEB') {
+               $browser = 'and_uc';
+       }
        s/\.0$// for $version;
 }