Skip to content

Commit

Permalink
修复拦截链接错误
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxianxu committed Feb 21, 2024
1 parent 5619355 commit 5d6d95e
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 118 deletions.
1 change: 1 addition & 0 deletions App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
// this.globalData.webview.plusInstall(violentmonkey)
// 安装工具插件
this.globalData.webview.plusInstall(Tools)
// this.globalData.webview.plusInstall(Tools)
const domModule = uni.requireNativePlugin('dom');
domModule.addRule('fontFace', {
fontFamily: 'ccfffasd',
Expand Down
3 changes: 3 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

如果支持作者,可以点击一下广告,算是让作者有继续写下去的动力。

## 体验
最新体验安装包 [UnibrowserScript3](https://github.com/SHEE94/UnibrowserScript3/releases)

## 联系作者

如果想请作者喝杯咖啡可以加作者QQ:549859890
Expand Down
77 changes: 45 additions & 32 deletions libs/browser.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class WebView extends EventEmitter {
})
}

this.state.data.Plugins = []

this.parent = null;

this.height = system.screenHeight - system.statusBarHeight - 44;
Expand Down Expand Up @@ -107,7 +109,7 @@ class WebView extends EventEmitter {
}
}
});

// uni.onKeyboardHeightChange((res)=>{
// let height = res.height;
// console.log(height)
Expand All @@ -117,7 +119,7 @@ class WebView extends EventEmitter {
// this.full = false;
// }
// })

}

setStyle(style) {
Expand Down Expand Up @@ -193,7 +195,7 @@ class WebView extends EventEmitter {
* @param {Object} id 窗口id
*/
closeWindow(id) {

_webviews.forEach((item, index) => {
if (item.id == id) {
item.removeFromParent()
Expand Down Expand Up @@ -340,13 +342,13 @@ class WebView extends EventEmitter {
})
}, 1000)
})
wv.addEventListener('rendering',()=>{
wv.addEventListener('rendering', () => {
this.emit(EVENT_TYPE['loading'], wv)
wv.allRes = [];
})

wv.addEventListener('loading', () => {

wv.allRes = [];
this.emit(EVENT_TYPE['loading'], wv)
})
Expand All @@ -358,10 +360,10 @@ class WebView extends EventEmitter {


}



getStrOrigin(val){


getStrOrigin(val) {
let text = '';
if (val && typeof val === 'string') {
const reg = /((https|http|ftp|file):\/\/)([A-Za-z0-9\-.]+)(:[0-9]+){0,1}/g;
Expand All @@ -372,44 +374,44 @@ class WebView extends EventEmitter {
}
return text;
}

/**
* 将网页安装为app
*/
installWebapp(options){
if(!options){
installWebapp(options) {
if (!options) {
options = {
name:this.activeWebview.getTitle(),
icon:this.getIco(),
toast:'',
extra:{
'url':this.getURL()
name: this.activeWebview.getTitle(),
icon: this.getIco(),
toast: '',
extra: {
'url': this.getURL()
}
}
}
plus.navigator.createShortcut(options,(e)=>{
const sure=e.sure;
if(e.sure){
plus.navigator.createShortcut(options, (e) => {
const sure = e.sure;
if (e.sure) {
uni.showToast({
icon:'success',
title:'创建成功'
icon: 'success',
title: '创建成功'
})
}else{
} else {
uni.showToast({
icon:'error',
title:'创建失败'
icon: 'error',
title: '创建失败'
})
}
});
}
getIco(){

getIco() {
const activeWeview = this.checkedActiveWebview();
return this.getStrOrigin(activeWeview.getURL())+'/favicon.ico';
return this.getStrOrigin(activeWeview.getURL()) + '/favicon.ico';
}

/**
* 获取cookie
* 设置cookie
* @param {String} name
* @param {String} value
* @param {Number} days
Expand All @@ -432,7 +434,7 @@ class WebView extends EventEmitter {
}

/**
* 设置cookie
* 获取cookie
* @param {Object} url 获取cookie的地址,默认当前网页
* @param {Object} id 获取指定webview窗口
*/
Expand Down Expand Up @@ -519,8 +521,19 @@ class WebView extends EventEmitter {
* @param {Object} p
*/
plusInstall(plusFunc) {
if (typeof plusFunc !== 'function') return;
if (typeof plusFunc !== 'function' && typeof plusFunc !== 'object') return;
let Plugins = this.state.data.Plugins||[];
if (Plugins.indexOf(plusFunc) > -1) {
console.warn('Plug-in installed')
return;
}
if (typeof plusFunc === 'object' && typeof plusFunc.install === 'function') {
plusFunc.install(this)
return;
}
plusFunc(this)
Plugins.push(plusFunc)
this.state.data.Plugins = Plugins
}
/**
* @description 设置当前活动的webview
Expand Down Expand Up @@ -651,5 +664,5 @@ export {
Setting,
Tools,
ScriptExtension,
Violentmonkey
Violentmonkey,EVENT_TYPE,ACTION_TYPR
}
5 changes: 4 additions & 1 deletion libs/src/setting/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export default class History {
})
}
}


/**
* @param {Boolean} val
*/
set privacyMode(val) {
this.wv.state.data.privacyMode = val;
}
Expand Down
6 changes: 2 additions & 4 deletions libs/src/setting/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Setting {
if (res.tapIndex == 0) {
blacklist.push(getStrOrigin(
url))
this.state.data.blackUrls =
this.wv.state.data.blackUrls =
blacklist;
} else if (res.tapIndex == 1) {
this.wv.openNewWindow(url)
Expand Down Expand Up @@ -499,14 +499,12 @@ class Setting {
})
}



/**
* 重置
*/
reset() {
uni.removeStorageSync('settingConfig');
this._settingConfig = settingConfig;
this.settingConfig = settingConfig;
}
get settingConfig() {
return this.wv.state.data.settingConfig || this._settingConfig;
Expand Down
8 changes: 5 additions & 3 deletions libs/src/tools/ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const blackClassList = uni.getStorageSync('blackClassList') || [];
export default class AD {
constructor(wv) {
this.wv = wv;
console.log(regStr)
if(!blackUrls.length){

if (!blackUrls.length) {
blackUrls = [regStr]
}
this.wv.state.setData({
Expand All @@ -19,6 +19,7 @@ export default class AD {
})
})
this.wv.state.watch('blackUrls', (val) => {
if (!val || !val.length) return;
uni.setStorage({
key: 'blackUrls',
data: val
Expand Down Expand Up @@ -75,7 +76,8 @@ export default class AD {
*/
addBlackAD(url) {
if (!url) return;
blackUrls.push(url);
blackUrls = this.wv.state.data.blackUrls || blackUrls;
blackUrls.push(url)
this.wv.state.data.blackUrls = blackUrls;
let code = this.injectClearADCode();
this.wv.activeWebview.evalJS(code)
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name" : "Script Browser 3",
"appid" : "__UNI__A92EF1E",
"description" : "",
"versionName" : "3.0.4",
"versionCode" : 304,
"versionName" : "3.0.6",
"versionCode" : 306,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
Expand Down

0 comments on commit 5d6d95e

Please sign in to comment.