Skip to content

Instantly share code, notes, and snippets.

@DaMandal0rian
Last active January 30, 2018 20:46
Show Gist options
  • Select an option

  • Save DaMandal0rian/d9a996b9d33a1f662cd644cacbd89265 to your computer and use it in GitHub Desktop.

Select an option

Save DaMandal0rian/d9a996b9d33a1f662cd644cacbd89265 to your computer and use it in GitHub Desktop.

Revisions

  1. Muhammad Perreira revised this gist Jan 30, 2018. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion hmtl guid storage
    Original file line number Diff line number Diff line change
    @@ -19,11 +19,20 @@ function generate_guid() {
    });
    }

    function get_guid() {
    function get_local_guid() {
    if (window.localStorage.guid != null) {
    return window.localStorage.guid;
    } else {
    window.localStorage.guid = generate_guid();
    return window.localStorage.guid;
    }
    }

    function get_session_guid() {
    if (window.sessionStorage.getItem("guid") != null) {
    return window.sessionStorage.getItem("guid");
    } else {
    window.sessionStorage.setItem("guid", generate_guid());
    return window.sessionStorage.getItem("guid");
    }
    }
  2. Muhammad Perreira created this gist Jan 30, 2018.
    29 changes: 29 additions & 0 deletions hmtl guid storage
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    var brwsr_guid = function() {

    var nav = window.navigator;
    var screen = window.screen;
    var guid = nav.mimeTypes.length;
    guid += nav.userAgent.replace(/\D+/g, '');
    guid += nav.plugins.length;
    guid += screen.height || '';
    guid += screen.width || '';
    guid += screen.pixelDepth || '';

    return guid;
    };

    function generate_guid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
    return v.toString(16);
    });
    }

    function get_guid() {
    if (window.localStorage.guid != null) {
    return window.localStorage.guid;
    } else {
    window.localStorage.guid = generate_guid();
    return window.localStorage.guid;
    }
    }