Skip to content

Commit

Permalink
Ability to use FireMonkey as script manager
Browse files Browse the repository at this point in the history
  • Loading branch information
SthephanShinkufag committed Sep 2, 2021
1 parent 7fb7dce commit 3ab8660
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 32 deletions.
21 changes: 16 additions & 5 deletions Dollchan_Extension_Tools.user.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 18 additions & 9 deletions extension/Dollchan_Extension_Tools.es6.user.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 18 additions & 9 deletions src/Dollchan_Extension_Tools.es6.user.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions src/modules/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,29 @@ function initNavFuncs() {
const isChrome = isWebkit && ua.includes('Chrome/');
const isSafari = isWebkit && !isChrome;
const hasPrestoStorage = !!prestoStorage && !ua.includes('Opera Mobi');
const hasNewGM = /* global GM */ typeof GM !== 'undefined' && typeof GM.xmlHttpRequest === 'function';
const canUseFetch = 'AbortController' in deWindow; // Firefox 57+, Chrome 66+, Safari 11.1+
let scriptHandler, hasWebStorage = false;
let hasGMXHR = false;
let hasOldGM = false;
let hasNewGM = /* global GM */ typeof GM !== 'undefined' && typeof GM.xmlHttpRequest === 'function';
if(hasNewGM) {
scriptHandler = GM.info ? `${ GM.info.scriptHandler } ${ GM.info.version }` : 'Greasemonkey';
const inf = GM.info;
const handlerName = inf ? inf.scriptHandler : '';
scriptHandler = inf ? handlerName + ' ' + inf.version : 'Greasemonkey';
if(handlerName === 'FireMonkey') {
hasOldGM = true;
hasNewGM = false;
} else {
hasGMXHR = typeof GM.xmlHttpRequest === 'function';
}
} else {
try {
hasOldGM = (typeof GM_setValue === 'function') &&
(!isChrome || !GM_setValue.toString().includes('not supported'));
} catch(err) {
hasOldGM = err.message === 'Permission denied to access property "toString"'; // Chrome
}
hasGMXHR = typeof GM_xmlhttpRequest === 'function';
hasWebStorage = !hasOldGM && (isFirefox || ('chrome' in deWindow)) &&
(typeof chrome === 'object') && !!chrome && !!chrome.storage;
scriptHandler = hasWebStorage ? 'WebExtension' :
Expand Down Expand Up @@ -98,21 +108,20 @@ function initNavFuncs() {
firefoxVer : isFirefox ? +(ua.match(/Firefox\/(\d+)/) || [0, 0])[1] : 0,
fixLink : isSafari ? getAbsLink : url => url,
hasGlobalStorage : hasOldGM || hasNewGM || hasWebStorage || hasPrestoStorage,
hasGMXHR : (typeof GM_xmlhttpRequest === 'function') ||
hasNewGM && (typeof GM.xmlHttpRequest === 'function'),
hasGMXHR,
hasNewGM,
hasOldGM,
hasPrestoStorage,
hasWebStorage,
isChrome,
isESNext : typeof deMainFuncOuter === 'undefined',
isESNext : typeof deMainFuncOuter === 'undefined',
isFirefox,
isMsEdge : ua.includes('Edge/'),
isPresto : !!deWindow.opera,
isMsEdge : ua.includes('Edge/'),
isPresto : !!deWindow.opera,
isSafari,
isWebkit,
scriptHandler,
ua : navigator.userAgent + (isFirefox ? ` [${ navigator.buildID }]` : ''),
ua : navigator.userAgent + (isFirefox ? ` [${ navigator.buildID }]` : ''),

get canPlayMP3() {
const value = !!new Audio().canPlayType('audio/mpeg;');
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

const version = '21.7.6.0';
const commit = '04948a5';
const commit = '7fb7dce';

/* ==[ DefaultCfg.js ]== */
/* ==[ Localization.js ]== */
Expand Down

1 comment on commit 3ab8660

@SthephanShinkufag
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solves #1404

Please sign in to comment.