bug1769762-tiktok.com-plugins-shim.js (1303B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Bug 1769762 - Empty out navigator.plugins 9 * WebCompat issue #103612 - https://webcompat.com/issues/103612 10 * 11 * Certain features of the site are breaking if navigator.plugins array is not empty: 12 * 13 * 1. "Likes" on the comments are not saved 14 * 2. Can't reply to other people's comments 15 * 3. "Likes" on the videos are not saved 16 * 4. Can't follow an account (after refreshing "Follow" button is visible again) 17 * 18 * (note that the first 2 are still broken if you open devtools even with this intervention) 19 */ 20 21 /* globals exportFunction */ 22 23 console.info( 24 "The PluginArray has been overridden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1753874 for details." 25 ); 26 27 const pluginsArray = new window.wrappedJSObject.Array(); 28 Object.setPrototypeOf(pluginsArray, PluginArray.prototype); 29 const navProto = Object.getPrototypeOf(navigator.wrappedJSObject); 30 const pluginsDesc = Object.getOwnPropertyDescriptor(navProto, "plugins"); 31 pluginsDesc.get = exportFunction(() => pluginsArray, window); 32 Object.defineProperty(navProto, "plugins", pluginsDesc);