MediaWiki:Gadget-libPolyfill-crypto.randomUUID.js
外观
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
/**
* -------------------------------------------------------------------------
* !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
* -------------------------------------------------------------------------
*/
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/libPolyfill/Gadget-libPolyfill-crypto.randomUUID.js|user=[[U:AnnAngela]]|co-authors=GH:github-actions[bot]|longId=103d1a563ea4ccc8ff29fb55c9bcd88329a56eb5|shortId=103d1a56|summary=feat: rename (#594)|body=<nowiki>Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}';
/* <pre> */
"use strict";
/**
* Generated by scripts/generatePolyfill/index.js
* Options:
* polyfillFeature: crypto.randomUUID
* polyfillAliases: default
* targetChromiumVersion: 86.0.0
* polyfillVersionRange: <92.0.0-0 (<92)
*/ (function() {
// Polyfill crypto.randomUUID start
/**
* 引自 uuid@9.0.0
*/ /**
* @source https://github.com/uuidjs/uuid/blob/v9.0.0/src/regex.js
*/ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
/**
* @source https://github.com/uuidjs/uuid/blob/v9.0.0/src/validate.js
*/ var validate = function(uuid) {
return "string" === typeof uuid && REGEX.test(uuid);
};
/**
* @source https://github.com/uuidjs/uuid/blob/v9.0.0/src/rng-browser.js
*/ var rnds8 = new Uint8Array(16);
var rng = function() {
return crypto.getRandomValues(rnds8);
};
/**
* @source https://github.com/uuidjs/uuid/blob/v9.0.0/src/stringify.js
*/ var byteToHex = [];
for(var i = 0; i < 256; ++i){
byteToHex.push((i + 256).toString(16).substring(1));
}
var unsafeStringify = function(arr) {
var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
return "".concat(byteToHex[arr[offset + 0]]).concat(byteToHex[arr[offset + 1]]).concat(byteToHex[arr[offset + 2]]).concat(byteToHex[arr[offset + 3]], "-").concat(byteToHex[arr[offset + 4]]).concat(byteToHex[arr[offset + 5]], "-").concat(byteToHex[arr[offset + 6]]).concat(byteToHex[arr[offset + 7]], "-").concat(byteToHex[arr[offset + 8]]).concat(byteToHex[arr[offset + 9]], "-").concat(byteToHex[arr[offset + 10]]).concat(byteToHex[arr[offset + 11]]).concat(byteToHex[arr[offset + 12]]).concat(byteToHex[arr[offset + 13]]).concat(byteToHex[arr[offset + 14]]).concat(byteToHex[arr[offset + 15]]).toLowerCase();
};
/**
* @source https://github.com/uuidjs/uuid/blob/v9.0.0/src/v4.js
*/ var v4 = function() {
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, buf = arguments.length > 1 ? arguments[1] : void 0, offset = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
var rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 0x0f | 0x40;
rnds[8] = rnds[8] & 0x3f | 0x80;
if (buf) {
for(var i = 0; i < 16; ++i){
buf[offset + i] = rnds[i];
}
return buf;
}
return unsafeStringify(rnds);
};
/**
* main polyfill
*/ try {
if (!validate(crypto.randomUUID())) {
throw void 0;
}
} catch (e) {
crypto.randomUUID = function() {
return v4();
};
}
// Polyfill crypto.randomUUID end
})();
/* </pre> */