Skip to content

Web Intent implementation. We will say Goodbye Android Browser!

License

Notifications You must be signed in to change notification settings

androidaftermarket/ChromeTrigger.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChromeTrigger.js Build Status

npm

Web Intent implementation. We will say Goodbye Android Browser!

Document

How to use

Browser

<script src="../lib/IntentDialog.js"></script>
<script src="../lib/ChromeTrigger.js"></script>

<script type="text/template" id="js-intent-dialog-template">
  <div id="js-intent-dialog" style="display:none">
    <style>
        (omit)
    </style>
    <div class="frame">
        (omit)
    </div>
  </div>
</script>
<script>
function isGoodByeAndroidBrowser() { // @ret Boolean
                                     // @see https://github.com/uupaa/Browser.js/wiki/isGoodByeAndroidBrowser
    var ua = navigator.userAgent;

    if ( !/Android/.test(ua) ) { // has not "Android" token
        return false;
    }
    if ( /Silk|Firefox/.test(ua) ) { // kindle or Android Firefox
        return false;
    }
    var ver = parseFloat(ua.split("Android")[1].split(";")[0]) || 0.0;

    if (ver < 4.0 || ver >= 4.4) {
        return false;
    }
    // check unsupported functions.
    // see: http://caniuse.com/#compare=chrome+30,android+4.2-4.3,android+4.4
    if (typeof Worker !== "undefined" ||
        typeof requestAnimationFrame !== "undefined") {
        return false;
    }
    return true;
}
</script>
<script>
var debug = true;
var goodbye = isGoodByeAndroidBrowser();

if (debug) {
    goodbye = true;
}
if (goodbye) {
  //var param = { url: location.href };
    var param = { url: "http://caniuse.com/#compare=ios_saf+7.0-7.1,ios_saf+8,android+4.2-4.3,android+4.4,and_chr+0" };

    if (debug) {
        ChromeTrigger.resetAlwaysSetting();
    }
    ChromeTrigger.ready(function() {
        ChromeTrigger.open(param, function(always) {
            alert("Selected Android browser. " + (always ? "always" : "once"));
        });
    });
}
</script>

About

Web Intent implementation. We will say Goodbye Android Browser!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published