Skip to content

Instantly share code, notes, and snippets.

@PrintNow
Created April 18, 2025 04:14
Show Gist options
  • Save PrintNow/af43a6b027ff837a2acffaff3ad5afa0 to your computer and use it in GitHub Desktop.
Save PrintNow/af43a6b027ff837a2acffaff3ad5afa0 to your computer and use it in GitHub Desktop.
秀姑「划词翻译」对 Shopify.dev 网站样式破坏
// ==UserScript==
// @name 修复 Shopify x 划词翻译插件冲突
// @namespace http://nowtime.cc.net/
// @version 2025-04-18
// @description try to take over the world!
// @author Shine
// @match https://shopify.dev/docs/api/admin-graphql/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=shopify.dev
// @grant none
// ==/UserScript==
(function () {
'use strict';
// 获取 <html> 元素
const targetElement = document.querySelector(`html`);
// 创建一个 MutationObserver 实例
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList' && mutation.target.tagName === 'HTML') {
// 重新实时查询
const $HTML = document.querySelector(`html`).classList;
if (!$HTML.contains('Mode-Light')) {
// 取消监听
observer.disconnect();
$HTML.add('Mode-Light');
}
}
});
});
// 配置观察器选项
const config = {
// attributes: true, // 监听属性变化
// attributeFilter: ['class'], // 仅监听 class 属性变化
// subtree: true, // 仅监听指定的元素,不监听子元素
childList: true,
};
// 启动监听
observer.observe(targetElement, config);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment