Skip to content

Commit

Permalink
updated 添加360浏览器判断
Browse files Browse the repository at this point in the history
  • Loading branch information
mumuy committed Jul 12, 2024
1 parent d4b8579 commit 7c90db8
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dist/browser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/browser.min.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"userAgent": "",
};
let getTemplate = function(info){
let browserList = ['Chrome','Safari','Firefox','Edge','IE','Opera','360SE','360EE','360AI','QQBrowser','Sogou','Liebao','Maxthon','TheWorld','Quark','2345Explorer','115Browser','UC','QQ','Wechat','Yandex','Vivaldi','Vivo','Meizu','Xiaomi','OPPO','OnePlus','Huawei','HONOR','Lenovo','Brave','Alipay','Taobao','Toutiao'];
let browserList = ['Chrome','Safari','Firefox','Edge','IE','Opera','360','360SE','360EE','360AI','QQBrowser','Sogou','Liebao','Maxthon','TheWorld','Quark','2345Explorer','115Browser','UC','QQ','Wechat','Yandex','Vivaldi','Vivo','Meizu','Xiaomi','OPPO','OnePlus','Huawei','HONOR','Lenovo','Brave','Alipay','Taobao','Toutiao'];
return `
<table>
<tbody>
Expand Down
32 changes: 16 additions & 16 deletions src/module/browser-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,8 @@ export default function(_,isAsync = false){
_.browser = '';
_.browserVersion = '';

browserList.forEach(function(item){
if(item.match(ua)){
_.browser = item.name;
_.browserVersion = item.version(ua,isAsync);
}
});
// 修正
if(_.browser == 'Chrome'&&ua.match(/\S+Browser/)){
_.browser = ua.match(/\S+Browser/)[0];
_.browserVersion = ua.replace(/^.*Browser\/([\d.]+).*$/)?.[1]||'';
}
if(!_.browserVersion){
_.browserVersion = ua.match(/Version\/([\d.]+)/)?.[1]||'';
}

if(isAsync){
let all_promise = wrapperPromise(browserList.map(item=>item.match(ua)));
let all_promise = wrapperPromise(browserList.map(item=>item.match(ua,isAsync)));
_.browser = Promise.all(all_promise).then(function(list){
let browser = '';
list.forEach(function(isMatch,index){
Expand Down Expand Up @@ -126,5 +111,20 @@ export default function(_,isAsync = false){
}
return version;
});
}else{
browserList.forEach(function(item){
if(item.match(ua)){
_.browser = item.name;
_.browserVersion = item.version(ua,isAsync);
}
});
// 修正
if(_.browser == 'Chrome'&&ua.match(/\S+Browser/)){
_.browser = ua.match(/\S+Browser/)[0];
_.browserVersion = ua.replace(/^.*Browser\/([\d.]+).*$/)?.[1]||'';
}
if(!_.browserVersion){
_.browserVersion = ua.match(/Version\/([\d.]+)/)?.[1]||'';
}
}
};
32 changes: 31 additions & 1 deletion src/module/browser/360SE.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,44 @@ import _globalThis from '../runtime/globalThis.js';

export default {
name:'360SE',
match(ua){
match(ua,isAsync=false){
let isMatch = false;
if(_360.match(ua)){
if(getMime("type", "application/gameplugin")){
isMatch = true;
}else if(_globalThis?.navigator?.userAgentData?.brands.filter(item=>item.brand=='Not.A/Brand').length){
isMatch = true;
}
if(!isMatch&&isAsync&&!document?.querySelector('#ai-assist-root')){
let $ai = document.createElement('div');
$ai.setAttribute('id','ai-assist-root');
document.body.appendChild($ai);
return new Promise(function(resolve,reject){
let isResolve = false;
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.type === 'childList') {
mutation.removedNodes.forEach(function($item){
if($item==$ai){
if(!isResolve){
isResolve = true;
resolve(true);
}
}
});
}
});
});
const config = { attributes: true, childList: true, subtree: true };
observer.observe(document.body, config);
setTimeout(function(){
if(!isResolve){
isResolve = true;
resolve(false);
}
},1500);
});
}
}
return ua.includes('360SE')||isMatch;
},
Expand Down
Binary file added static/image/icon/360.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7c90db8

Please sign in to comment.