-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: search with Reddit Repost Sleuth
Closes #132.
- Loading branch information
Showing
10 changed files
with
158 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {findNode} from 'utils/common'; | ||
import {setFileInputData, initSearch, sendReceipt} from 'utils/engines'; | ||
|
||
const engine = 'repostSleuth'; | ||
|
||
async function search({task, search, image, storageKeys}) { | ||
if (search.method === 'upload') { | ||
const inputSelector = 'input[type=file]'; | ||
const input = await findNode(inputSelector); | ||
|
||
await setFileInputData(inputSelector, input, image); | ||
|
||
await sendReceipt(storageKeys); | ||
|
||
input.dispatchEvent(new Event('change')); | ||
} else { | ||
const input = await findNode('input[placeholder="https://redd.it/xyz"]'); | ||
|
||
input.value = image.imageUrl; | ||
|
||
await sendReceipt(storageKeys); | ||
|
||
input.dispatchEvent(new Event('input')); | ||
} | ||
|
||
(await findNode('main button.primary')).click(); | ||
} | ||
|
||
function init() { | ||
initSearch(search, engine, sessionKey); | ||
} | ||
|
||
init(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import browser from 'webextension-polyfill'; | ||
|
||
const message = 'Add Reddit Repost Sleuth'; | ||
|
||
const revision = 'K9Esw2jiQ3'; | ||
const downRevision = 'IMMjiccGj'; | ||
|
||
const storage = browser.storage.local; | ||
|
||
async function upgrade() { | ||
const changes = {}; | ||
const {engines, disabledEngines} = await storage.get([ | ||
'engines', | ||
'disabledEngines' | ||
]); | ||
|
||
changes.engines = engines.concat('repostSleuth'); | ||
changes.disabledEngines = disabledEngines.concat('repostSleuth'); | ||
|
||
changes.storageVersion = revision; | ||
return storage.set(changes); | ||
} | ||
|
||
async function downgrade() { | ||
const changes = {}; | ||
const {engines, disabledEngines} = await storage.get([ | ||
'engines', | ||
'disabledEngines' | ||
]); | ||
|
||
changes.engines = engines.filter(function (item) { | ||
return item !== 'repostSleuth'; | ||
}); | ||
changes.disabledEngines = disabledEngines.filter(function (item) { | ||
return item !== 'repostSleuth'; | ||
}); | ||
|
||
changes.storageVersion = downRevision; | ||
return storage.set(changes); | ||
} | ||
|
||
export {message, revision, upgrade, downgrade}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
"UhWEtK9gMh", | ||
"TshBYj8anA", | ||
"ggrr9C9pgV", | ||
"IMMjiccGj" | ||
"IMMjiccGj", | ||
"K9Esw2jiQ3" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import browser from 'webextension-polyfill'; | ||
|
||
const message = 'Add Reddit Repost Sleuth'; | ||
|
||
const revision = 'K9Esw2jiQ3'; | ||
const downRevision = 'IMMjiccGj'; | ||
|
||
const storage = browser.storage.sync; | ||
|
||
async function upgrade() { | ||
const changes = {}; | ||
const {engines, disabledEngines} = await storage.get([ | ||
'engines', | ||
'disabledEngines' | ||
]); | ||
|
||
changes.engines = engines.concat('repostSleuth'); | ||
changes.disabledEngines = disabledEngines.concat('repostSleuth'); | ||
|
||
changes.storageVersion = revision; | ||
return storage.set(changes); | ||
} | ||
|
||
async function downgrade() { | ||
const changes = {}; | ||
const {engines, disabledEngines} = await storage.get([ | ||
'engines', | ||
'disabledEngines' | ||
]); | ||
|
||
changes.engines = engines.filter(function (item) { | ||
return item !== 'repostSleuth'; | ||
}); | ||
changes.disabledEngines = disabledEngines.filter(function (item) { | ||
return item !== 'repostSleuth'; | ||
}); | ||
|
||
changes.storageVersion = downRevision; | ||
return storage.set(changes); | ||
} | ||
|
||
export {message, revision, upgrade, downgrade}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
"UhWEtK9gMh", | ||
"TshBYj8anA", | ||
"ggrr9C9pgV", | ||
"IMMjiccGj" | ||
"IMMjiccGj", | ||
"K9Esw2jiQ3" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters