1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 | Object.defineProperty(window, "browser", {
|
6 | value: {
|
7 | userAgent: navigator.userAgent,
|
8 | name: navigator.appName,
|
9 | version: navigator.appVersion,
|
10 | isMobile: ["Android", "iPhone", "iPod", "Windows Phone", "Mobile", "Coolpad", "mmp", "SmartPhone", "midp", "wap", "xoom", "Symbian", "J2ME", "Blackberry", "Wince"].some(function (value) { return navigator.userAgent.exists(value); }),
|
11 | isChrome: /\(KHTML, like Gecko\) Chrome\//.test(navigator.userAgent),
|
12 | isFirefox: navigator.userAgent.exists("Firefox"),
|
13 | isMozilla: navigator.userAgent.exists("Mozilla"),
|
14 | isEdge: navigator.userAgent.exists("Edge"),
|
15 | isMSIE: navigator.userAgent.exists("MSIE") && navigator.userAgent.exists("compatible"),
|
16 | isOpera: navigator.userAgent.exists("Opera"),
|
17 | isSafari: navigator.userAgent.exists("Safari"),
|
18 | isNetscape: /Netscape([\d]*)\/([^\s]+)/i.test(navigator.userAgent)
|
19 | },
|
20 | configurable: true,
|
21 | writable: false
|
22 | });
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | Window.prototype.copy = function (str) {
|
29 | try {
|
30 | if (Object.isObject(this.clipboardData)) {
|
31 | this.clipboardData.setData("text", str);
|
32 | }
|
33 | else {
|
34 | var fakeElement = document.createElement("textarea");
|
35 | fakeElement.style.border = "none";
|
36 | fakeElement.style.margin = "0";
|
37 | fakeElement.style.padding = "0";
|
38 | fakeElement.style.position = "absolute";
|
39 | fakeElement.style.top = "-9999px";
|
40 | fakeElement.style.left = "-9999px";
|
41 | fakeElement.value = str;
|
42 | fakeElement.setAttribute("readonly", "");
|
43 | document.body.appendChild(fakeElement);
|
44 | fakeElement.setSelectionRange(0, str.length);
|
45 | fakeElement.select();
|
46 | document.execCommand("copy");
|
47 | fakeElement.remove();
|
48 | }
|
49 | }
|
50 | catch (e) {
|
51 | console.error(e);
|
52 | }
|
53 | };
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | Location.prototype.getParameters = function () {
|
60 | var queryString = this.search;
|
61 | var parameters = {};
|
62 | if (queryString.indexOf("?") != -1) {
|
63 | queryString = queryString.substring(1);
|
64 | var parts = queryString.split("&");
|
65 | for (var i = 0; i < parts.length; i++) {
|
66 | var temp = parts[i].split("=");
|
67 | var val = temp.length == 2 ? encodeURIComponent(temp[1]) : "";
|
68 | if (Object.isUndefined(parameters[temp[0]])) {
|
69 | parameters[temp[0]] = val;
|
70 | }
|
71 | else {
|
72 | if (Object.isArray(parameters[temp[0]]) == false) {
|
73 | var oldVal = parameters[temp[0]];
|
74 | delete parameters[temp[0]];
|
75 | parameters[temp[0]] = [oldVal];
|
76 | }
|
77 | parameters[temp[0]].push(val);
|
78 | }
|
79 | }
|
80 | }
|
81 | return parameters;
|
82 | };
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | Location.prototype.getParameter = function (name) {
|
90 | var parameters = this.getParameters();
|
91 | return parameters[name];
|
92 | };
|
93 |
|
\ | No newline at end of file |