PluginProbe
Extendify / 3.0.5
Extendify v3.0.5
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Agent / lib / media-views.js

media-views.js in Extendify 3.0.5, at src/Agent/lib/media-views.js

89 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const CUSTOM_CSS_ELEMENT_ID = 'media-views-important';
2
3 const processRules = (rules) => {
4 const result = [];
5
6 [...rules].forEach((rule) => {
7 switch (rule.type) {
8 case CSSRule.STYLE_RULE:
9 result.push(addImportant(rule));
10 break;
11 case CSSRule.MEDIA_RULE:
12 result.push(`@media ${rule.conditionText} {`);
13 processRules(rule.cssRules, result);
14 result.push('}');
15 break;
16 default:
17 result.push(rule.cssText);
18 break;
19 }
20 });
21
22 return result;
23 };
24
25 const addImportant = (rule) => {
26 const declarations = [...rule.style].map(
27 (prop) => `${prop}: ${rule.style.getPropertyValue(prop)} !important`,
28 );
29
30 return `${rule.selectorText} { ${declarations.join('; ')}; }`;
31 };
32
33 const getCustomMediaViewsCss = () => {
34 const link = document.getElementById('media-views-css');
35 if (!link) return null;
36
37 const processedRules = processRules(link.sheet?.cssRules);
38
39 if (!processedRules?.length) return null;
40
41 const css = processedRules.join('\n');
42
43 const additionalCSS = `
44 div:has(> .media-modal) {z-index: 999999 !important}
45 .media-frame {
46 h1, h2, h3, h4, h5, h6 {
47 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
48 color: #1d2327 !important;
49 }
50
51 .uploader-inline-content {
52 color: #1d2327 !important;
53 }
54
55 .media-sidebar {
56 color: #646970 !important;
57 }
58
59 .media-search-input-label,
60 .load-more-count {
61 color: #3c434a !important;
62 }
63 }
64 `;
65
66 return `${additionalCSS} ${css}`;
67 };
68
69 export const addCustomMediaViewsCss = () => {
70 if (document.getElementById(CUSTOM_CSS_ELEMENT_ID)) return;
71
72 const css = getCustomMediaViewsCss();
73
74 if (!css) return;
75
76 const style = document.createElement('style');
77
78 style.id = CUSTOM_CSS_ELEMENT_ID;
79 style.textContent = css;
80
81 document.head.appendChild(style);
82 };
83
84 export const removeCustomMediaViewsCss = () => {
85 const style = document.getElementById(CUSTOM_CSS_ELEMENT_ID);
86
87 if (style) style.remove();
88 };
89