Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
mdovhopo committed Dec 5, 2021
0 parents commit f978b39
Show file tree
Hide file tree
Showing 7 changed files with 28,736 additions and 0 deletions.
36 changes: 36 additions & 0 deletions hot-reload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const filesInDirectory = dir => new Promise (resolve =>
dir.createReader ().readEntries (entries =>
Promise.all (entries.filter (e => e.name[0] !== '.').map (e =>
e.isDirectory
? filesInDirectory (e)
: new Promise (resolve => e.file (resolve))
))
.then (files => [].concat (...files))
.then (resolve)
)
)

const timestampForFilesInDirectory = dir =>
filesInDirectory (dir).then (files =>
files.map (f => f.name + f.lastModifiedDate).join ())

const watchChanges = (dir, lastTimestamp) => {
timestampForFilesInDirectory (dir).then (timestamp => {
if (!lastTimestamp || (lastTimestamp === timestamp)) {
setTimeout (() => watchChanges (dir, timestamp), 1000) // retry after 1s
} else {
chrome.runtime.reload ()
}
})
}

chrome.management.getSelf (self => {
if (self.installType === 'development') {
chrome.runtime.getPackageDirectoryEntry (dir => watchChanges (dir))
chrome.tabs.query ({ active: true, lastFocusedWindow: true }, tabs => { // NB: see https://github.com/xpl/crx-hotreload/issues/5
if (tabs[0]) {
chrome.tabs.reload (tabs[0].id)
}
})
}
})
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Ebay research",
"version": "0.0.1",
"manifest_version": 2,
"author": "rollun.com",

"background": { "scripts": ["hot-reload.js"] },

"browser_action": {
"default_title": "Ebay - research lots faster",
"default_icon": "icon.png"
},

"icons": {
"128": "icon.png"
},

"content_scripts": [{
"matches": ["https://www.ebay.com/sh/research?*"],
"js": [
"react.development.js",
"react-dom.development.js",
"script.js"
],
"css": ["styles.css"],
"run_at": "document_end"
}],

"permissions": []
}
Loading

0 comments on commit f978b39

Please sign in to comment.