|
3 | 3 | // @description Adds the magic of AI to Amazon shopping |
4 | 4 | // @author KudoAI |
5 | 5 | // @namespace https://kudoai.com |
6 | | -// @version 2025.1.26.16 |
| 6 | +// @version 2025.1.26.17 |
7 | 7 | // @license MIT |
8 | 8 | // @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7 |
9 | 9 | // @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7 |
|
61 | 61 | // @require https://cdn.jsdelivr.net/npm/@kudoai/[email protected]/dist/chatgpt.min.js#sha256-+C0x4BOFQc38aZB3pvUC2THu+ZSvuCxRphGdtRLjCDg= |
62 | 62 | // @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js#sha256-dppVXeVTurw1ozOPNE3XqhYmDJPOosfbKQcHyQSE58w= |
63 | 63 | // @require https://assets.aiwebextensions.com/lib/crypto-utils.js/dist/crypto-utils.min.js?v=9e1e11d#sha256-bx3N1EAkmOTOFXxeyalh+IJnadXqVFHMBIPjRczmnEk= |
| 64 | +// @require https://assets.aiwebextensions.com/lib/dom.js/dist/dom.min.js?v=a724796#sha256-oP9HSQKyQERkYfYRaQYxM3FIO9KXkgl/4tW55zjbGeE= |
64 | 65 | // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/generate-ip.min.js#sha256-aQQKAQcMgCu8IpJp9HKs387x0uYxngO+Fb4pc5nSF4I= |
65 | 66 | // @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js#sha256-g3pvpbDHNrUrveKythkPMF2j/J7UFoHbUyFQcFe1yEY= |
66 | 67 | // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js#sha256-n0UwfFeU7SR6DQlfOmLlLvIhWmeyMnIDp/2RmVmuedE= |
|
408 | 409 | suggestOpenAI: `${app.msgs.alert_try} ${app.msgs.alert_switchingOff} ${app.msgs.mode_proxy}` |
409 | 410 | }}) |
410 | 411 |
|
| 412 | + // Export DEPENDENCIES to dom.js |
| 413 | + dom.imports.import({ config, env }) // for config.bgAnimationsDisabled + env.ui.scheme in dom.fillStarryBg() |
| 414 | + |
411 | 415 | // Define MENU functions |
412 | 416 |
|
413 | 417 | const menu = { |
|
1865 | 1869 | Object.entries(headerElems).forEach(([key, elem]) => { |
1866 | 1870 | if (elem && key == 'byline' && getComputedStyle(elem).display == 'none') |
1867 | 1871 | elem.style.cssText += forceDisplayStyles // override hidden byline display style to measure width |
1868 | | - widths[key] = dom.getComputedWidth(elem) |
| 1872 | + widths[key] = dom.get.computedWidth(elem) |
1869 | 1873 | if (elem?.style?.cssText.includes(forceDisplayStyles)) // restore display style for hidden byline |
1870 | 1874 | elem.style.cssText = elem.style.cssText.replace(forceDisplayStyles, '') |
1871 | 1875 | }) |
|
3024 | 3028 | } |
3025 | 3029 | } |
3026 | 3030 |
|
3027 | | - // Define DOM utilities |
3028 | | - |
3029 | | - const dom = { |
3030 | | - |
3031 | | - create: { |
3032 | | - anchor(linkHref, displayContent, attrs = {}) { |
3033 | | - const anchor = document.createElement('a'), |
3034 | | - defaultAttrs = { href: linkHref, target: '_blank', rel: 'noopener' }, |
3035 | | - finalAttrs = { ...defaultAttrs, ...attrs } |
3036 | | - Object.entries(finalAttrs).forEach(([attr, value]) => anchor.setAttribute(attr, value)) |
3037 | | - if (displayContent) anchor.append(displayContent) |
3038 | | - return anchor |
3039 | | - }, |
3040 | | - |
3041 | | - style(content) { |
3042 | | - const style = document.createElement('style') |
3043 | | - if (content) style.innerText = content |
3044 | | - return style |
3045 | | - }, |
3046 | | - |
3047 | | - svgElem(type, attrs) { |
3048 | | - const elem = document.createElementNS('http://www.w3.org/2000/svg', type) |
3049 | | - for (const attr in attrs) elem.setAttributeNS(null, attr, attrs[attr]) |
3050 | | - return elem |
3051 | | - } |
3052 | | - }, |
3053 | | - |
3054 | | - fillStarryBG(targetNode) { // requires https://assets.aiwebextensions.com/styles/rising-stars/css/<black|white>.min.css |
3055 | | - if (targetNode.querySelector('[id*=stars]')) return |
3056 | | - const starsDivsContainer = document.createElement('div') |
3057 | | - starsDivsContainer.style.cssText = 'position: absolute ; top: 0 ; left: 0 ;' // hug targetNode's top-left corner |
3058 | | - + 'height: 100% ; width: 100% ; border-radius: 15px ; overflow: clip ;' // bound innards exactly by targetNode |
3059 | | - + 'z-index: -1'; // allow interactive elems to be clicked |
3060 | | - ['sm', 'med', 'lg'].forEach(starSize => { |
3061 | | - const starsDiv = document.createElement('div') |
3062 | | - starsDiv.id = config.bgAnimationsDisabled ? `stars-${starSize}-off` |
3063 | | - : `${ env.ui.app.scheme == 'dark' ? 'white' : 'black' }-stars-${starSize}` |
3064 | | - starsDivsContainer.append(starsDiv) |
3065 | | - }) |
3066 | | - targetNode.prepend(starsDivsContainer) |
3067 | | - }, |
3068 | | - |
3069 | | - getComputedWidth(...elems) { // including margins |
3070 | | - let totalWidth = 0 |
3071 | | - elems.map(arg => arg instanceof NodeList ? [...arg] : arg).flat().forEach(elem => { |
3072 | | - if (!(elem instanceof Element)) return |
3073 | | - const elemStyle = getComputedStyle(elem) ; if (elemStyle.display == 'none') return |
3074 | | - totalWidth += elem.getBoundingClientRect().width + parseFloat(elemStyle.marginLeft) |
3075 | | - + parseFloat(elemStyle.marginRight) |
3076 | | - }) |
3077 | | - return totalWidth |
3078 | | - } |
3079 | | - } |
3080 | | - |
3081 | 3031 | // Run MAIN routine |
3082 | 3032 |
|
3083 | 3033 | menu.register() |
|
0 commit comments