mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 15:27:32 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
60
mobile/ios/Client/Assets/Favicons.js
Normal file
60
mobile/ios/Client/Assets/Favicons.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
if (!window.__firefox__) {
|
||||
Object.defineProperty(window, '__firefox__', {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: {}
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(window.__firefox__, 'favicons', {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: (function() {
|
||||
// These integers should be kept in sync with the IconType raw-values
|
||||
var ICON = 0;
|
||||
var APPLE = 1;
|
||||
var APPLE_PRECOMPOSED = 2;
|
||||
var GUESS = 3;
|
||||
|
||||
var selectors = {
|
||||
"link[rel~='icon']": ICON,
|
||||
"link[rel='apple-touch-icon']": APPLE,
|
||||
"link[rel='apple-touch-icon-precomposed']": APPLE_PRECOMPOSED
|
||||
};
|
||||
|
||||
function getAll() {
|
||||
var favicons = {};
|
||||
|
||||
for (var selector in selectors) {
|
||||
var icons = document.querySelectorAll(selector);
|
||||
for (var i = 0; i < icons.length; i++) {
|
||||
var href = icons[i].href;
|
||||
favicons[href] = selectors[selector];
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't find anything in the page, look to see if a favicon.ico file exists for the domain
|
||||
if (Object.keys(favicons).length === 0) {
|
||||
var href = document.location.origin + "/favicon.ico";
|
||||
favicons[href] = GUESS;
|
||||
}
|
||||
return favicons;
|
||||
}
|
||||
|
||||
function getFavicons() {
|
||||
var favicons = getAll();
|
||||
webkit.messageHandlers.faviconsMessageHandler.postMessage(favicons);
|
||||
}
|
||||
|
||||
return {
|
||||
getFavicons: getFavicons
|
||||
};
|
||||
})()
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue