
v_console_log = console.log
var v_saf;
!function () {
    var n = Function.toString, t = [], i = [], o = [].indexOf.bind(t), e = [].push.bind(t), r = [].push.bind(i);

    function u(n, t, nn) {
        tt = ''
        if (nn) {
            tt = ' ' + nn
        }
        return -1 == o(n) && (e(n), r(`function${tt} ${t || n.name || ""}() { [native code] }`)), n
    }

    Object.defineProperty(Function.prototype, "toString", {
        enumerable: !1,
        configurable: !0,
        writable: !0,
        value: function () {
            let res = "function" == typeof this && i[o(this)] || n.call(this)
            // print('toString', arguments, '|||', 'res', res)

            return res;
        }
    }), u(Function.prototype.toString, "toString"), v_saf = u
}();
Location = v_saf(function Location() {
})

let _origin = '';
function set_href(v, href){
            href = href.trim()
            v_console_log(`  href[set]:`, JSON.stringify(href))
            if (href.startsWith("http://") || href.startsWith("https://")) {/*ok*/
            } else if (href.startsWith("//")) {
                href = (v.protocol ? v.protocol : 'http:') + href
            } else {
                href = v.protocol + "//" + v.host + (v.port ? ":" + v.port : "") + '/' + ((href[0] == '/') ? href.slice(1) : href)
            }
            var a = href.match(/([^:]+:)\/\/([^/:?#]+):?(\d+)?([^?#]*)?(\?[^#]*)?(#.*)?/);
            v.protocol = a[1] ? a[1] : "";
            v.host = a[2] ? a[2] : "";
            v.port = a[3] ? a[3] : "";
            v.pathname = a[4] ? a[4] : "";
            v.search = a[5] ? a[5] : "";
            v.hash = a[6] ? a[6] : "";
            v.hostname = this.host;
            v.origin = this.protocol + "//" + this.host + (this.port ? ":" + this.port : "");
}
Object.defineProperties(Location.prototype, {
    href: {
        get: function () {
            if (!(this.protocol) && !(this.host)) {
                r = ''
            } else {
                r = this.protocol + "//" + this.host + (this.port ? ":" + this.port : "") + this.pathname + this.search + this.hash;
            }
            // v_console_log(`  [*] ${name||obj.constructor.name} -> href[get]:`, JSON.stringify(r))
            return r
        },
        set: function (href) {
            href = href.trim()
            v_console_log(`  href[set]:`, JSON.stringify(href))
            if (href.startsWith("http://") || href.startsWith("https://")) {/*ok*/
            } else if (href.startsWith("//")) {
                href = (this.protocol ? this.protocol : 'http:') + href
            } else {
                href = this.protocol + "//" + this.host + (this.port ? ":" + this.port : "") + '/' + ((href[0] == '/') ? href.slice(1) : href)
            }
            var a = href.match(/([^:]+:)\/\/([^/:?#]+):?(\d+)?([^?#]*)?(\?[^#]*)?(#.*)?/);
            this.protocol = a[1] ? a[1] : "";
            this.host = a[2] ? a[2] : "";
            this.port = a[3] ? a[3] : "";
            this.pathname = a[4] ? a[4] : "";
            this.search = a[5] ? a[5] : "";
            this.hash = a[6] ? a[6] : "";
            this.hostname = this.host;
            this.origin = this.protocol + "//" + this.host + (this.port ? ":" + this.port : "");
        },
        enumerable:true
    },
    assign: {
        value: v_saf(function assign() {

        }),
        enumerable: true,

    },
    ancestorOrigins: {
        get: v_saf(function ancestorOrigins() {
            return new DOMStringList()
        }),
        enumerable: true,
        configurable: false,

    },
    // fragmentDirective: 'c',
    // hash: {set: function(arg){_hash = arg}, get:function(){return _hash}, enumerable:true},
    // host: {set: function(arg){_host = arg}, get:function(){return _host}, enumerable:true},
    // hostname: {set: function(arg){_hostname = arg}, get:function(){return _hostname}, enumerable:true},
    origin: {
        set: function (arg) {
            _origin = arg
        }, get: function () {
            return _origin
        }, enumerable: true
    },
    // pathname: {set: function(arg){_pathname = arg}, get:function(){return _pathname}, enumerable:true},
    // port: {set: function(arg){_port = arg}, get:function(){return _port}, enumerable:true},
    // protocol: {set: function(arg){_protocol = arg}, get:function(){return _protocol}, enumerable:true},
    // host: 'e',
    // hostname: 'f',
    // href: 'g',
    // origin: 'h',
    // pathname: 'i',
    // port: 'j',
    // protocol: 'k',
    reload: {
        value: v_saf(function reload() {

        }),
        enumerable: true,

    },
    replace: {
        value: v_saf(function replace() {

        }),
        enumerable: true,
    },
    toString: {
        value: v_saf(function toString() {
            return ''
        }),
        enumerable: true,

    },
    _protocol: {enumerable:false},
    _hostname: {enumerable:false},
    _port: {enumerable:false},
    _pathname: {enumerable:false},
    _hash: {enumerable:false},
    _origin: {enumerable:false},
})


location = new Location

console.log(Object.getOwnPropertyNames(location))
// v_hook_href(location, "location", 'https://www.jetblue.com/booking/flights?from=LAS&to=BOS&depart=2023-07-10&isMultiCity=false&noOfRoute=1&lang=en&adults=1&children=0&infants=0&sharedMarket=false&roundTripFaresFlag=false&usePoints=false')
location.__proto__ = Location.prototype
console.log(Object.getOwnPropertyNames(location))


DOMStringList = v_saf(function DOMStringList() {

})
Object.defineProperties(location, {
    ancestorOrigins: {
        get: v_saf(function ancestorOrigins() {
            return new DOMStringList()
        }),
        enumerable: true,
        configurable: false

    },
    href: {
    value: 'https://www.jetblue.com/booking/flights?from=LAS&to=BOS&depart=2023-07-10&isMultiCity=false&noOfRoute=1&lang=en&adults=1&children=0&infants=0&sharedMarket=false&roundTripFaresFlag=false&usePoints=false',
    enumerable: true
    },
// 'valueOf,ancestorOrigins,href,origin,protocol,host,hostname,port,pathname,search,hash,assign,reload,replace,toString'
//          ancestorOrigins,href,origin,protocol,host,hostname,port,pathname,hash,assign,reload,replace,toString
    // fragmentDirective: 'c',
    origin: {set: function(arg){_origin = arg}, get:function(){return _origin}, enumerable:true},
    protocol: {set: function(arg){_protocol = arg}, get:function(){return _protocol}, enumerable:true},
    host: {set: function(arg){_hostname = arg}, get:function(){return _hostname}, enumerable:true},
    hostname: {set: function(arg){_hostname = arg}, get:function(){return _hostname}, enumerable:true},
    port: {set: function(arg){_port = arg}, get:function(){return _port}, enumerable:true},
    pathname: {set: function(arg){_pathname = arg}, get:function(){return _pathname}, enumerable:true},
    search: {set: function(arg){_pathname = arg}, get:function(){return _pathname}, enumerable:true},
    hash: {set: function(arg){_hash = arg}, get:function(){return _hash}, enumerable:true},
    // host: 'e',
    // hostname: 'f',
    // href: 'g',
    // origin: 'h',
    // pathname: 'i',
    // port: 'j',
    // protocol: 'k',
    assign: {
        value: v_saf(function assign() {

        }),
        enumerable: true,

    },
    reload: {
        value: v_saf(function reload() {

        }),
        enumerable: true,

    },
    replace: {
        value: v_saf(function replace() {

        }),
        enumerable: true,
    },
    toString: {
        value: v_saf(function toString() {
            return ''
        }),
        enumerable: true,

    },


})
function set_href(v, href){
            href = href.trim()
            v_console_log(`  href[set]:`, JSON.stringify(href))
            if (href.startsWith("http://") || href.startsWith("https://")) {/*ok*/
            } else if (href.startsWith("//")) {
                href = (v.protocol ? v.protocol : 'http:') + href
            } else {
                href = v.protocol + "//" + v.host + (v.port ? ":" + v.port : "") + '/' + ((href[0] == '/') ? href.slice(1) : href)
            }
            var a = href.match(/([^:]+:)\/\/([^/:?#]+):?(\d+)?([^?#]*)?(\?[^#]*)?(#.*)?/);
            v.protocol = a[1] ? a[1] : "";
            v.host = a[2] ? a[2] : "";
            v.port = a[3] ? a[3] : "";
            v.pathname = a[4] ? a[4] : "";
            v.search = a[5] ? a[5] : "";
            v.hash = a[6] ? a[6] : "";
            v.hostname = this.host;
            v.origin = this.protocol + "//" + this.host + (this.port ? ":" + this.port : "");
}
// 'valueOf,ancestorOrigins,href,origin,protocol,host,hostname,port,pathname,search,hash,assign,reload,replace,toString'
set_href(location, 'https://www.jetblue.com/booking/flights?from=LAS&to=BOS&depart=2023-07-10&isMultiCity=false&noOfRoute=1&lang=en&adults=1&children=0&infants=0&sharedMarket=false&roundTripFaresFlag=false&usePoints=false')
// Object.defineProperties(location, {
//     href: {
//         value: 'https://www.jetblue.com/booking/flights?from=LAS&to=BOS&depart=2023-07-10&isMultiCity=false&noOfRoute=1&lang=en&adults=1&children=0&infants=0&sharedMarket=false&roundTripFaresFlag=false&usePoints=false',
//         enumerable: true
//     }
// })

console.log(Object.getOwnPropertyNames(location)+'')
console.log(location.hostname)


let b = function (){}

console.log(Object.hasOwnProperty(b, 'prototype'))