Skip to content

Instantly share code, notes, and snippets.

View daybrush's full-sized avatar
😀
HAHAHAHAHAHA

Daybrush (Younkue Choi) daybrush

😀
HAHAHAHAHAHA
View GitHub Profile
@daybrush
daybrush / ios.js
Last active September 4, 2020 07:10
import getAgent from "@egjs/agent";
const agent = getAgent();
if (
agent.os.name === "ios"
&& (agent.os.majorVersion >= 10 || agent.isHints)
) {
console.log("is iOS");
import getAgent from "@egjs/agent";
const agent = getAgent();
if (
agent.os.name === "android"
&& (agent.os.majorVersion >= 5 || agent.isHints) {
console.log("is Android >= 5");
}
import getAgent from "@egjs/agent";
const agent = getAgent();
if ((agent.os.name === "mac" || agent.os.name === "ios") && agent.browser.webkit) {
console.log("is mac, ios webkit");
}
import { getAccurateAgent } from "@egjs/agent";
// Use Promise
getAccurateAgent().then(agent => {
// Mac OS X 10.15.4, Chrome Canary 87.0.4243.0
// "chrome"
agent.browser.name
// "87.0.4243.0"
agent.browser.version
import getAgent from "@egjs/agent";
const agent = getAgent();
// Mac OS X 10.15.4, Chrome Canary 87.0.4243.0
// "chrome"
agent.browser.name
// "87" (before "87.0.4243.0")
agent.browser.version
// "unknown" (before mac)
// chromium's engine(blink) is based on applewebkit 537.36.
export const CHROMIUM_PRESETS: PresetInfo[] = [
{
test: "(?=.*applewebkit/(53[0-7]|5[0-2]|[0-4]))(?=.*\\schrome)",
id: "chrome",
},
{
test: "chromium",
id: "chrome",
import getAgent from "@egjs/agent";
const agent = getAgent();
// check Mac
export const isMacintosh = agent.os.name === "mac";
// for pc mode in iOS
export const isIOS = (isMacintosh || agent.os.name === "ios") && !!navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
@daybrush
daybrush / getHighEntropyValues.js
Created September 1, 2020 09:38
getHighEntropyValues.js
navigator.userAgentData.getHighEntropyValues([
"architecture",
"model",
"platform",
"platformVersion",
"uaFullVersion",
]).then(info => {
console.log(info);
});
dictionary NavigatorUABrandVersion {
DOMString brand;
DOMString version;
};
dictionary UADataValues {
DOMString platform;
DOMString platformVersion;
DOMString architecture;
DOMString model;
@daybrush
daybrush / navigator_id.cc
Created September 1, 2020 07:15
navigator_id.cc (freeze userAgent)
String NavigatorID::platform() const {
// If the User-Agent string is frozen, platform should be a value
// matching the frozen string per https://github.com/WICG/ua-client-hints. See
// content::frozen_user_agent_strings.
if (base::FeatureList::IsEnabled(features::kFreezeUserAgent)) {
#if defined(OS_ANDROID)
// Matches the frozen mobile User-Agent string (arbitrary Android device).
return "Linux armv8l";
#else
// Matches the frozen desktop User-Agent string (Windows).