Skip to content

Commit

Permalink
tmp: use local selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
dbajpeyi committed Oct 8, 2024
1 parent 8dc3174 commit 9ae50c9
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 75 deletions.
80 changes: 43 additions & 37 deletions build/integration/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -22066,23 +22066,26 @@
scale: 1,
backgroundColor: 'rgba(0, 39, 142, 0.5)'
},
element: await this.findSettingsElement()
element: await this.findSettingsElement(),
shouldTap: this.#settingsButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/options') {
return {
style: {
scale: 1.01,
backgroundColor: 'rgba(0, 39, 142, 0.5)'
},
element: this.findExportElement()
element: await this.findExportElement(),
shouldTap: this.#exportButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/intro') {
return {
style: {
scale: 1.5,
backgroundColor: 'rgba(0, 39, 142, 0.5)'
},
element: this.findSignInButton()
element: await this.findSignInButton(),
shouldTap: this.#signInButtonSettings.autotap?.enabled ?? false
}
} else {
return null
Expand All @@ -22096,9 +22099,9 @@
inline: 'center'
}); // Scroll into view
const keyframes = [
{ backgroundColor: 'rgba(0, 0, 255, 0)', offset: 0 }, // Start: transparent
{ backgroundColor: style.backgroundColor, offset: 0.5, transform: `scale(${style.scale})` }, // Midpoint: blue with 50% opacity
{ backgroundColor: 'rgba(0, 0, 255, 0)', offset: 1 } // End: transparent
{ backgroundColor: 'rgba(0, 0, 255, 0)', offset: 0, borderRadus: '2px' }, // Start: transparent
{ backgroundColor: style.backgroundColor, offset: 0.5, borderRadius: '2px', transform: `scale(${style.scale})` }, // Midpoint: blue with 50% opacity
{ backgroundColor: 'rgba(0, 0, 255, 0)', borderRadius: '2px', offset: 1 } // End: transparent
];

// Define the animation options
Expand All @@ -22115,23 +22118,23 @@
element.click();
}

findExportElement () {
return withExponentialBackoff(() => getElement(document, this.exportButtonXpath))
async findExportElement () {
return await withExponentialBackoff(() => getElement(document, this.exportButtonSelector))
}

findSettingsElement () {
return withExponentialBackoff(() => document.querySelector(this.settingsButtonSelector))
async findSettingsElement () {
return await withExponentialBackoff(() => document.querySelector(this.settingsButtonSelector))
}

findSignInButton () {
return withExponentialBackoff(() => document.querySelector('[aria-label="Sign in"]:not([target="_top"])'))
async findSignInButton () {
return await withExponentialBackoff(() => document.querySelector(this.signinButtonSelector))
}

async handleElementForPath (path) {
const animateElement = this.animateElement.bind(this);
const { element, style } = await this.getElementAndStyleFromPath(path) ?? {};
if (element) {
animateElement(element, style);
const { element, style, shouldTap } = await this.getElementAndStyleFromPath(path) ?? {};
if (element != null) {
shouldTap ? this.autotapElement() : animateElement(element, style);
}
}

Expand All @@ -22143,34 +22146,37 @@
: null
}

get exportButtonXpath () {
if (this.exportButtonAnimationType === 'autotap') {
return this.#exportButtonSettings.autotap?.xpath
} else if (this.exportButtonAnimationType === 'highlight') {
return this.#exportButtonSettings.highlight?.xpath
} else {
return null
}
get exportButtonSelector () {
return '[aria-label="Export"]'
// if (this.exportButtonAnimationType === 'autotap') {
// return this.#exportButtonSettings.autotap?.xpath
// } else if (this.exportButtonAnimationType === 'highlight') {
// return this.#exportButtonSettings.highlight?.xpath
// } else {
// return null
// }
}

get signinButtonSelector () {
if (this.exportButtonAnimationType === 'autotap') {
return this.#signInButtonSettings.autotap?.selector
} else if (this.exportButtonAnimationType === 'highlight') {
return this.#signInButtonSettings.highlight?.selector
} else {
return null
}
return '[aria-label="Sign in"]:not([target="_top"])'
// if (this.exportButtonAnimationType === 'autotap') {
// return this.#signInButtonSettings.autotap?.selector
// } else if (this.exportButtonAnimationType === 'highlight') {
// return this.#signInButtonSettings.highlight?.selector
// } else {
// return null
// }
}

get settingsButtonSelector () {
if (this.exportButtonAnimationType === 'autotap') {
return this.#settingsButtonSettings.autotap?.selector
} else if (this.exportButtonAnimationType === 'highlight') {
return this.#settingsButtonSettings.highlight?.selector
} else {
return null
}
return '[aria-label=\'Password options\']'
// if (this.exportButtonAnimationType === 'autotap') {
// return this.#settingsButtonSettings.autotap?.selector
// } else if (this.exportButtonAnimationType === 'highlight') {
// return this.#settingsButtonSettings.highlight?.selector
// } else {
// return null
// }
}

setButtonSettings (settings) {
Expand Down
80 changes: 43 additions & 37 deletions src/features/password-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,26 @@ export default class PasswordImport extends ContentFeature {
scale: 1,
backgroundColor: 'rgba(0, 39, 142, 0.5)'
},
element: await this.findSettingsElement()
element: await this.findSettingsElement(),
shouldTap: this.#settingsButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/options') {
return {
style: {
scale: 1.01,
backgroundColor: 'rgba(0, 39, 142, 0.5)'
},
element: this.findExportElement()
element: await this.findExportElement(),
shouldTap: this.#exportButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/intro') {
return {
style: {
scale: 1.5,
backgroundColor: 'rgba(0, 39, 142, 0.5)'
},
element: this.findSignInButton()
element: await this.findSignInButton(),
shouldTap: this.#signInButtonSettings.autotap?.enabled ?? false
}
} else {
return null
Expand All @@ -44,9 +47,9 @@ export default class PasswordImport extends ContentFeature {
inline: 'center'
}) // Scroll into view
const keyframes = [
{ backgroundColor: 'rgba(0, 0, 255, 0)', offset: 0 }, // Start: transparent
{ backgroundColor: style.backgroundColor, offset: 0.5, transform: `scale(${style.scale})` }, // Midpoint: blue with 50% opacity
{ backgroundColor: 'rgba(0, 0, 255, 0)', offset: 1 } // End: transparent
{ backgroundColor: 'rgba(0, 0, 255, 0)', offset: 0, borderRadus: '2px' }, // Start: transparent
{ backgroundColor: style.backgroundColor, offset: 0.5, borderRadius: '2px', transform: `scale(${style.scale})` }, // Midpoint: blue with 50% opacity
{ backgroundColor: 'rgba(0, 0, 255, 0)', borderRadius: '2px', offset: 1 } // End: transparent
]

// Define the animation options
Expand All @@ -63,23 +66,23 @@ export default class PasswordImport extends ContentFeature {
element.click()
}

findExportElement () {
return withExponentialBackoff(() => getElement(document, this.exportButtonXpath))
async findExportElement () {
return await withExponentialBackoff(() => getElement(document, this.exportButtonSelector))
}

findSettingsElement () {
return withExponentialBackoff(() => document.querySelector(this.settingsButtonSelector))
async findSettingsElement () {
return await withExponentialBackoff(() => document.querySelector(this.settingsButtonSelector))
}

findSignInButton () {
return withExponentialBackoff(() => document.querySelector('[aria-label="Sign in"]:not([target="_top"])'))
async findSignInButton () {
return await withExponentialBackoff(() => document.querySelector(this.signinButtonSelector))
}

async handleElementForPath (path) {
const animateElement = this.animateElement.bind(this)
const { element, style } = await this.getElementAndStyleFromPath(path) ?? {}
if (element) {
animateElement(element, style)
const { element, style, shouldTap } = await this.getElementAndStyleFromPath(path) ?? {}
if (element != null) {
shouldTap ? this.autotapElement() : animateElement(element, style)
}
}

Expand All @@ -91,34 +94,37 @@ export default class PasswordImport extends ContentFeature {
: null
}

get exportButtonXpath () {
if (this.exportButtonAnimationType === 'autotap') {
return this.#exportButtonSettings.autotap?.xpath
} else if (this.exportButtonAnimationType === 'highlight') {
return this.#exportButtonSettings.highlight?.xpath
} else {
return null
}
get exportButtonSelector () {
return '[aria-label="Export"]'
// if (this.exportButtonAnimationType === 'autotap') {
// return this.#exportButtonSettings.autotap?.xpath
// } else if (this.exportButtonAnimationType === 'highlight') {
// return this.#exportButtonSettings.highlight?.xpath
// } else {
// return null
// }
}

get signinButtonSelector () {
if (this.exportButtonAnimationType === 'autotap') {
return this.#signInButtonSettings.autotap?.selector
} else if (this.exportButtonAnimationType === 'highlight') {
return this.#signInButtonSettings.highlight?.selector
} else {
return null
}
return '[aria-label="Sign in"]:not([target="_top"])'
// if (this.exportButtonAnimationType === 'autotap') {
// return this.#signInButtonSettings.autotap?.selector
// } else if (this.exportButtonAnimationType === 'highlight') {
// return this.#signInButtonSettings.highlight?.selector
// } else {
// return null
// }
}

get settingsButtonSelector () {
if (this.exportButtonAnimationType === 'autotap') {
return this.#settingsButtonSettings.autotap?.selector
} else if (this.exportButtonAnimationType === 'highlight') {
return this.#settingsButtonSettings.highlight?.selector
} else {
return null
}
return '[aria-label=\'Password options\']'
// if (this.exportButtonAnimationType === 'autotap') {
// return this.#settingsButtonSettings.autotap?.selector
// } else if (this.exportButtonAnimationType === 'highlight') {
// return this.#settingsButtonSettings.highlight?.selector
// } else {
// return null
// }
}

setButtonSettings (settings) {
Expand Down
27 changes: 26 additions & 1 deletion src/types/webcompat-settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ export interface WebCompatSettings {
undefined: string[];
};
};
modifyLocalStorage?: {
state: State;
changes: {
key: string;
action: string;
}[];
};
notification?: {
state: State;
};
permissions?: {
state: State;
supportedPermissions: {};
};
mediaSession?: State;
presentation?: State;
webShare?: State;
viewportWidth?:
| State
| {
state: State;
forcedDesktopValue?: string;
forcedMobileValue?: string;
};
screenLock?: State;
domains?: Domains;
}
export interface Domain {
Expand All @@ -53,5 +78,5 @@ export interface PatchSetting {
/**
* The value to replace at the specified path
*/
value: string;
value: string | unknown[] | {} | number;
}

0 comments on commit 9ae50c9

Please sign in to comment.