Skip to content

Commit

Permalink
fix: add website prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
AXeL-dev committed Mar 12, 2022
1 parent 32ed834 commit eb6c2ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/helpers/block.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { translate } from './i18n';
import { isSmallDevice } from './device';
import { isAndroidDevice } from './device';
import { getHostname, isUrl } from './url';
import { sendMessage, storage, getActiveTab, createWindow, indexUrl } from './webext';

Expand Down Expand Up @@ -136,7 +136,8 @@ export async function addCurrentWebsite(mode, isPrompt = false, exactUrl = false
if (tab) {
const url = exactUrl ? `${tab.url}$` : `*.${getHostname(tab.url)}`;
if (isPrompt) {
if (isSmallDevice()) {
const isAndroid = await isAndroidDevice();
if (isAndroid) {
const response = window.prompt(translate('addWebsite'), url);
if (response !== null && isUrl(response)) {
blockUrl(response, mode, tab.id);
Expand Down
10 changes: 10 additions & 0 deletions src/helpers/device.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import { isWebExtension } from './webext';

export function isSmallDevice() {
return window.innerWidth < 900;
}

export async function isAndroidDevice() {
if (!isWebExtension) {
return false;
}
const platform = await browser.runtime.getPlatformInfo();
return platform.os === 'android';
}

0 comments on commit eb6c2ee

Please sign in to comment.