Skip to content

Commit

Permalink
updated 浏览器完善
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaole committed Sep 26, 2024
1 parent 776da84 commit f4249c9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/browser.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/browser.min.mjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/module/browser-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,15 @@ export default {
browserVersion = ua.match(/Version\/([\d.]+)/)?.[1]||'';
}

let cookieEnabled = globalThis?.navigator?.cookieEnabled;

return {
browser,
browserVersion,
engine,
isWebview,
isRobot,
cookieEnabled,
userAgent:ua
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/language-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
return {};
},
async getInfo(){
let g = globalThis?.navigator?.language||globalThis?.navigator?.browserLanguage;
let g = globalThis?.navigator?.language||globalThis?.navigator?.browserLanguage||globalThis?.navigator?.systemLanguage;
if (typeof g !== 'string') return 'Unknown language'
let arr = g.split('-');
if (arr[1]) {
Expand Down
8 changes: 6 additions & 2 deletions src/module/screen-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ export default {
// 屏幕尺寸
let screenWidth = globalThis?.screen?.width||0;
let screenHeight = globalThis?.screen?.height||0;
let clientWidth = globalThis?.document?.documentElement?.clientWidth||0;
let clientHeight = globalThis?.document?.documentElement?.clientHeight||0;
let clientWidth = globalThis?.document?.documentElement?.clientWidth||globalThis?.document?.body?.clientWidth||0;
let clientHeight = globalThis?.document?.documentElement?.clientHeight||globalThis?.document?.body?.clientHeight||0;
// 屏幕刷新率
let screenFPS = await getScreenFPS();
let screenColorDepth = globalThis?.screen.colorDepth;
let screenPixelDepth = globalThis?.screen.pixelDepth;
let isTouch = globalThis?.navigator?.maxTouchPoints>0||false;

return {
Expand All @@ -49,6 +51,8 @@ export default {
clientWidth,
clientHeight,
screenFPS,
screenColorDepth,
screenPixelDepth,
isTouch
};
}
Expand Down
26 changes: 26 additions & 0 deletions static/script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,24 @@ let getTemplate = function(info){
<span class="text-gray">FPS</span>
</td>
</tr>
<tr>
<td class="th">
<p class="title">屏幕颜色深度</p>
<p class="subtitle">Screen ColorDepth</p>
</td>
<td>
<span>${info.screenColorDepth?info.screenColorDepth+'-bit':''}</span>
</td>
</tr>
<tr>
<td class="th">
<p class="title">屏幕像素深度</p>
<p class="subtitle">Screen PixelDepth</p>
</td>
<td>
<span>${info.screenPixelDepth?info.screenPixelDepth+'-bit':''}</span>
</td>
</tr>
<tr>
<td class="th">
<p class="title">处理器架构</p>
Expand Down Expand Up @@ -292,6 +310,13 @@ let getTemplate = function(info){
</td>
<td>${info.isTouch?'是 <span class="text-gray">(true)</span>':'否 <span class="text-gray">(false)</span>'}</td>
</tr>
<tr>
<td class="th">
<p class="title">Cookie是否可用</p>
<p class="subtitle">Cookie Enabled</p>
</td>
<td>${info.cookieEnabled?'是 <span class="text-gray">(true)</span>':'否 <span class="text-gray">(false)</span>'}</td>
</tr>
<tr>
<td class="th">
<p class="title">是否支持WebGL</p>
Expand All @@ -316,6 +341,7 @@ let getTemplate = function(info){
$module.innerHTML = getTemplate(info);

browser.getInfo().then(function(info){
console.log('[getInfo()]',info);
$module.innerHTML = getTemplate(info) + `
<iframe style="display:none;" src="https://passer-by.com/browser/stat.html?browser=${info.browser}&ua=${info.userAgent}" width="" height=""></iframe>
`;
Expand Down

0 comments on commit f4249c9

Please sign in to comment.