Skip to content

Commit eb6c2ee

Browse files
committed
fix: add website prompt
1 parent 32ed834 commit eb6c2ee

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/helpers/block.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { translate } from './i18n';
2-
import { isSmallDevice } from './device';
2+
import { isAndroidDevice } from './device';
33
import { getHostname, isUrl } from './url';
44
import { sendMessage, storage, getActiveTab, createWindow, indexUrl } from './webext';
55

@@ -136,7 +136,8 @@ export async function addCurrentWebsite(mode, isPrompt = false, exactUrl = false
136136
if (tab) {
137137
const url = exactUrl ? `${tab.url}$` : `*.${getHostname(tab.url)}`;
138138
if (isPrompt) {
139-
if (isSmallDevice()) {
139+
const isAndroid = await isAndroidDevice();
140+
if (isAndroid) {
140141
const response = window.prompt(translate('addWebsite'), url);
141142
if (response !== null && isUrl(response)) {
142143
blockUrl(response, mode, tab.id);

src/helpers/device.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
import { isWebExtension } from './webext';
2+
13
export function isSmallDevice() {
24
return window.innerWidth < 900;
35
}
6+
7+
export async function isAndroidDevice() {
8+
if (!isWebExtension) {
9+
return false;
10+
}
11+
const platform = await browser.runtime.getPlatformInfo();
12+
return platform.os === 'android';
13+
}

0 commit comments

Comments
 (0)