Skip to content

Instantly share code, notes, and snippets.

@cynecx
Created April 15, 2022 17:12
Show Gist options
  • Select an option

  • Save cynecx/cdd4c49da796156b393266c39d44b660 to your computer and use it in GitHub Desktop.

Select an option

Save cynecx/cdd4c49da796156b393266c39d44b660 to your computer and use it in GitHub Desktop.
Force Native Emoji Font (eg. Apple) on GitHub As Tampermonkey Script
(function () {
"use strict";
const originalCustomElements = window.customElements;
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(window, "customElements");
const newCustomElements = {
get(name) {
return originalCustomElements.get(name)
},
define(name, constructor, options) {
if (name === "g-emoji") {
Object.defineProperty(window, 'customElements', originalPropertyDescriptor);
const newConstructor = class extends constructor {
connectedCallback() {
if (this.hasAttribute('tone')) {
this.attributeChangedCallback('tone');
}
}
};
return originalCustomElements.define(name, newConstructor, options);
}
return originalCustomElements.define(name, constructor, options);
},
upgrade(root) {
return originalCustomElements.upgrade(root);
},
whenDefined(name) {
return originalCustomElements.whenDefined(name);
}
};
Object.defineProperty(window, 'customElements', {
enumerable: true,
configurable: true,
get: function () { return newCustomElements; }
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment