|
148 | 148 | // @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!) |
149 | 149 | // @author KudoAI |
150 | 150 | // @namespace https://kudoai.com |
151 | | -// @version 2025.5.17.18 |
| 151 | +// @version 2025.5.17.19 |
152 | 152 | // @license MIT |
153 | 153 | // @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076 |
154 | 154 | // @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076 |
|
2842 | 2842 | update.footerContent() |
2843 | 2843 |
|
2844 | 2844 | // APPEND DDGPT + footer to DDG |
2845 | | - const appElems = [app.div, app.footer] |
2846 | | - const appDivParentSelector = env.browser.isMobile || env.ui.site.isCentered ? '[data-area*=mainline]' |
2847 | | - : '[class*=sidebar]' |
2848 | | - const appDivParent = await new Promise(resolve => { |
2849 | | - const appDivParent = document.querySelector(appDivParentSelector) |
| 2845 | + app.elems = [app.div, app.footer] |
| 2846 | + app.div.parent = { |
| 2847 | + selector: env.browser.isMobile || env.ui.site.isCentered ? '[data-area*=mainline]' : '[class*=sidebar]' } |
| 2848 | + app.div.parent.div = await new Promise(resolve => { |
| 2849 | + const appDivParent = document.querySelector(app.div.parent.selector) |
2850 | 2850 | if (appDivParent) resolve(appDivParent) |
2851 | 2851 | else new MutationObserver((_, obs) => { |
2852 | | - const appDivParent = document.querySelector(appDivParentSelector) |
| 2852 | + const appDivParent = document.querySelector(app.div.parent.selector) |
2853 | 2853 | if (appDivParent) { obs.disconnect() ; resolve(appDivParent) } |
2854 | 2854 | }).observe(document.body, { childList: true, subtree: true }) |
2855 | 2855 | }) |
2856 | | - appDivParent.prepend(...appElems) |
2857 | | - appElems.forEach((elem, idx) => // fade in staggered |
| 2856 | + app.div.parent.div.prepend(...app.elems) |
| 2857 | + app.elems.forEach((elem, idx) => // fade in staggered |
2858 | 2858 | setTimeout(() => elem.classList.add('active'), idx * 550 - 200)) |
2859 | 2859 |
|
2860 | 2860 | // REPLACE appDivParent max-width w/ min-width for better UI |
2861 | | - if (!env.browser.isMobile) Object.assign(appDivParent.style, { maxWidth: '', minWidth: '448px' }) |
| 2861 | + if (!env.browser.isMobile) Object.assign(app.div.parent.div.style, { maxWidth: '', minWidth: '448px' }) |
2862 | 2862 |
|
2863 | 2863 | // REFERRALIZE links to support author |
2864 | 2864 | setTimeout(() => document.querySelectorAll('a[href^="https://www.amazon."]').forEach(anchor => { |
|
2901 | 2901 |
|
2902 | 2902 | // Observe sidebar for need to RAISE DDGPT as other extensions inject into it |
2903 | 2903 | const sidebarObserver = new MutationObserver(() => { |
2904 | | - if (appDivParent.firstChild != app.div) { |
2905 | | - appDivParent.prepend(...appElems) ; sidebarObserver.disconnect() } |
| 2904 | + if (app.div.parent.div.firstChild != app.div) { |
| 2905 | + app.div.parent.div.prepend(...app.elems) ; sidebarObserver.disconnect() } |
2906 | 2906 | }) |
2907 | | - sidebarObserver.observe(appDivParent, { subtree: true, childList: true }) |
| 2907 | + sidebarObserver.observe(app.div.parent.div, { subtree: true, childList: true }) |
2908 | 2908 | setTimeout(() => sidebarObserver.disconnect(), 5000) // don't observe forever |
2909 | 2909 |
|
2910 | 2910 | })() |
0 commit comments