Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Hide Umingle video overlays
- // @description Hide the Umingle logo and selected video controls
- // @version 0.2.0
- // @match https://umingle.com/video/*
- // @run-at document-start
- // @grant none
- // @sandbox raw
- // @inject-into page
- // ==/UserScript==
- (() => {
- 'use strict';
- const hostSelector =
- 'body > div.main.video > div.videoGridMain > div.videoWrapper.remote.noSelect';
- const elementsToHide = ['#flag', '#vol-control'];
- const roots = new WeakMap();
- const watchedRoots = new WeakSet();
- const originalAttachShadow = Element.prototype.attachShadow;
- function hideLogo(root) {
- const findAndHide = () => {
- for (const svg of root.querySelectorAll('svg')) {
- const text = (svg.textContent || '').replace(/\s+/g, '').toLowerCase();
- if (text.includes('umingle.com')) {
- svg.style.setProperty('display', 'none', 'important');
- }
- }
- };
- findAndHide();
- if (!watchedRoots.has(root)) {
- watchedRoots.add(root);
- new MutationObserver(findAndHide).observe(root, {
- subtree: true,
- childList: true,
- characterData: true
- });
- }
- }
- function scan() {
- const host = document.querySelector(hostSelector);
- const root = host && roots.get(host);
- if (root) hideLogo(root);
- for (const selector of elementsToHide) {
- const element = document.querySelector(selector);
- if (element) {
- element.style.setProperty('display', 'none', 'important');
- }
- }
- }
- Element.prototype.attachShadow = function (init) {
- const root = Reflect.apply(originalAttachShadow, this, [init]);
- roots.set(this, root);
- queueMicrotask(scan);
- return root;
- };
- new MutationObserver(scan).observe(document, {
- subtree: true,
- childList: true,
- attributes: true,
- attributeFilter: ['class', 'id']
- });
- scan();
- })();
Advertisement
Add Comment
Please, Sign In to add comment