-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71986f3
commit ff07fb5
Showing
4 changed files
with
28 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Checks if current browser is supported | ||
* To be injected to every scriptlet at build time | ||
* | ||
* @throws error on unsupported browser | ||
*/ | ||
export function checkCompatibility() { | ||
const isBrowserSupported = () => { | ||
// arr.every() is not used because missing global method | ||
// would throw ReferenceError when added to array | ||
return typeof fetch !== 'undefined' | ||
&& typeof Proxy !== 'undefined' | ||
&& typeof Reflect !== 'undefined' | ||
&& typeof Response !== 'undefined' | ||
&& typeof Array.prototype.includes !== 'undefined' | ||
&& typeof String.prototype.includes !== 'undefined' | ||
&& typeof String.prototype.startsWith !== 'undefined' | ||
&& typeof String.prototype.endsWith !== 'undefined' | ||
&& typeof Element.prototype.attachShadow !== 'undefined'; | ||
}; | ||
|
||
if (!isBrowserSupported()) { | ||
throw new Error('Browser is not supported by AdGuard Scriptlets.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.