-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
114 changed files
with
1,791 additions
and
1,274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,44 @@ | ||
import browserLoader from './module/browser-loader.js'; | ||
import deviceLoader from './module/device-loader.js'; | ||
import engineLoader from './module/engine-loader.js'; | ||
import systemLoader from './module/system-loader.js'; | ||
import deviceLoader from './module/device-loader.js'; | ||
import gpuLoader from './module/gpu-loader.js'; | ||
import languageLoader from './module/language-loader.js'; | ||
import networkLoader from './module/network-loader.js'; | ||
import batterykLoader from './module/battery-loader.js'; | ||
import otherLoader from './module/other-loader.js'; | ||
import globalObject from './module/runtime/globalThis.js'; | ||
|
||
import wrapperPromise from './module/method/wrapperPromise.js'; | ||
|
||
let getInfo = function(userAgent,isAsync = false){ | ||
let info = {}; | ||
info.userAgent = userAgent || globalObject?.navigator?.userAgent||''; | ||
[ | ||
browserLoader, | ||
deviceLoader, | ||
engineLoader, | ||
systemLoader, | ||
gpuLoader, | ||
languageLoader, | ||
networkLoader, | ||
batterykLoader, | ||
otherLoader | ||
].forEach(loader=>loader(info,isAsync)); | ||
return info; | ||
} | ||
import batteryLoader from './module/battery-loader.js'; | ||
import screenLoader from './module/screen-loader.js'; | ||
import languageLoader from './module/language-loader.js'; | ||
import timezoneLoader from './module/timezone-loader.js'; | ||
|
||
// 旧版同步获取 | ||
function browser(userAgent){ | ||
let info = getInfo(userAgent); | ||
for(let key in info){ | ||
if(typeof info[key]=='object'){ | ||
info[key] = ''; | ||
export default { | ||
parse(ua){ | ||
let data = {}; | ||
[ | ||
browserLoader, | ||
engineLoader, | ||
systemLoader, | ||
deviceLoader, | ||
].forEach(loader=>{ | ||
data = Object.assign(data,loader.parse(ua)); | ||
}); | ||
return data; | ||
}, | ||
async getInfo(list = ['browser','engine','system','device','gpu','network','battery','screen','language','timezone']){ | ||
let data = {}; | ||
let loaderList = [ | ||
browserLoader, | ||
engineLoader, | ||
systemLoader, | ||
deviceLoader, | ||
gpuLoader, | ||
networkLoader, | ||
batteryLoader, | ||
screenLoader, | ||
languageLoader, | ||
timezoneLoader | ||
].filter(loader=>list.includes(loader.name)); | ||
for(let loader of loaderList){ | ||
data = Object.assign(data,await loader.getInfo()); | ||
} | ||
return data; | ||
} | ||
return info; | ||
} | ||
|
||
// 新版异步获取 | ||
browser.getInfo = function(userAgent){ | ||
let info = getInfo(userAgent,true); | ||
let keys = Object.keys(info); | ||
let all_promise = wrapperPromise(Object.values(info)); | ||
return Promise.all(all_promise).then(list=>{ | ||
let result = {}; | ||
list.forEach(function(value,index){ | ||
result[keys[index]] = value; | ||
}); | ||
return result; | ||
}); | ||
}; | ||
|
||
export default browser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
import _globalThis from './runtime/globalThis.js'; | ||
import globalThis from './runtime/globalThis.js'; | ||
|
||
export default function(_){ | ||
if(_globalThis?.navigator?.getBattery){ | ||
_.isCharging = _globalThis.navigator.getBattery().then((battery) => { | ||
return battery?.charging; | ||
}); | ||
_.battery = _globalThis.navigator.getBattery().then((battery) => { | ||
return +battery?.level||-1; | ||
}); | ||
}else{ | ||
_.isCharging = true; | ||
_.battery = 1; | ||
export default { | ||
name:'battery', | ||
parse(){ | ||
return {}; | ||
}, | ||
async getInfo(){ | ||
let isCharging = true; | ||
let battery = 1; | ||
if(globalThis?.navigator?.getBattery){ | ||
isCharging = await globalThis.navigator.getBattery().then((battery) => { | ||
return battery?.charging; | ||
}); | ||
battery = await globalThis.navigator.getBattery().then((battery) => { | ||
return +battery?.level||-1; | ||
}); | ||
} | ||
|
||
return { | ||
isCharging, | ||
battery | ||
}; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import userAgent from '../runtime/userAgent.js'; | ||
|
||
export default { | ||
name:'115Browser', | ||
match(ua){ | ||
return ua.includes('115Browser'); | ||
}, | ||
version(ua){ | ||
return ua.match(/115Browser\/([\d.]+)/)?.[1]||''; | ||
parse(ua = userAgent){ | ||
return { | ||
is:ua.includes('115Browser'), | ||
version:ua.match(/115Browser\/([\d.]+)/)?.[1]||'' | ||
}; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import _Chrome from './Chrome.js'; | ||
import _globalThis from '../runtime/globalThis.js'; | ||
import userAgent from '../runtime/userAgent.js'; | ||
import globalThis from '../runtime/globalThis.js'; | ||
|
||
export default { | ||
name:'2345Explorer', | ||
match(ua){ | ||
let isMatch = _globalThis?.chrome&&(_globalThis?.chrome?.adblock2345||_globalThis?.chrome?.common2345); | ||
return ua.includes('2345Explorer') | ||
||ua.includes('Mb2345Browser') | ||
||ua.includes('2345chrome') | ||
||isMatch; | ||
}, | ||
version(ua){ | ||
parse(ua = userAgent){ | ||
let hash = { | ||
'109':'13.0', | ||
'69':'10.0', | ||
'55':'9.9' | ||
}; | ||
let chrome_version = parseInt(_Chrome.version(ua)); | ||
return ua.match(/2345Explorer\/([\d.]+)/)?.[1] | ||
||ua.match(/Mb2345Browser\/([\d.]+)/)?.[1] | ||
||hash[chrome_version] | ||
||''; | ||
let chrome_version = parseInt(_Chrome.parse(ua).version); | ||
return { | ||
is:ua.includes('2345Explorer') | ||
||ua.includes('Mb2345Browser') | ||
||ua.includes('2345chrome'), | ||
version:ua.match(/2345Explorer\/([\d.]+)/)?.[1] | ||
||ua.match(/Mb2345Browser\/([\d.]+)/)?.[1] | ||
||hash[chrome_version] | ||
||'' | ||
}; | ||
}, | ||
async is(){ | ||
let isMatch = this.parse().is; | ||
if(!isMatch){ | ||
isMatch = globalThis?.chrome&&(globalThis?.chrome?.adblock2345||globalThis?.chrome?.common2345); | ||
} | ||
return isMatch; | ||
} | ||
}; | ||
} |
Oops, something went wrong.