Skip to content

Commit

Permalink
Merge pull request #10 from nakasyou/support-new-cws
Browse files Browse the repository at this point in the history
Support new cws
  • Loading branch information
nakasyou authored Nov 17, 2023
2 parents 307ea8b + b743c46 commit daad302
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 21 deletions.
7 changes: 7 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@
"hono": "https://deno.land/x/[email protected]/mod.ts",
"fflate": "https://esm.sh/[email protected]",
"zod": "https://esm.sh/[email protected]"
},
"compilerOptions": {
"lib": [
"deno.window",
"DOM",
"ESNext"
]
}
}
11 changes: 0 additions & 11 deletions extension/content_scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,3 @@ const script = document.createElement("script")
script.type = "module"
script.src = chrome.extension.getURL("src/main.js")
document.head.append(script)

window.addEventListener("message", async (evt) => {
if (evt.data.msg === "send-crx") {
const blob = await fetch(evt.data.url).then(res=>res.blob())
window.postMessage({
msg: "crx-data",
blob,
})
}
})

2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"content_scripts": [
{
"matches": [
"*://chrome.google.com/webstore/*"
"*://chromewebstore.google.com/*"
],
"js": [
"content_scripts/main.js"
Expand Down
2 changes: 1 addition & 1 deletion extension/src/install/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const install = async (evt) => {
downloadAtag.href = `https://firecws.deno.dev/get-xpi/${extensionId}`
downloadAtag.download = "chrome_extention.xpi"

document.querySelector(".e-f-o").append(downloadAtag)
document.body.append(downloadAtag)

downloadAtag.click()
evt.target.textContent = "ダウンロードしました"
Expand Down
30 changes: 26 additions & 4 deletions extension/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { addInstallBtn } from "./steps/add-install-btn.js"
import { removeRecommendChrome } from "./steps/remove-recommend-chrome.js"
import { install, pre } from "./install/main.js"


let oldUrl = ""
/**
*
Expand All @@ -19,15 +18,38 @@ const urlChangeListener = (func) => {
setTimeout(urlChangeListener, 100, func)
}

let intervalId = null
urlChangeListener(async () => {
await waitWebstoreLoaded()
const thisUrlStore = {}

clearInterval(intervalId)
intervalId = setInterval(async () => {
removeRecommendChrome(thisUrlStore)

/**
* @type {HTMLButtonElement}
*/
const addChrome = document.querySelector(`button[jscontroller][jsaction][aria-describedby="i5"]`)
if (addChrome) {
addChrome.disabled = false
addChrome.onclick = install

}
//removeDefaultAddChromeBtn(thisUrlStore)

/*const installBtn = addInstallBtn()
pre({
installBtn
})
installBtn.addEventListener("click", install)*/
}, 100)
/*await waitWebstoreLoaded()
removeRecommendChrome()
removeDefaultAddChromeBtn()
const installBtn = addInstallBtn()
pre({
installBtn
})
installBtn.addEventListener("click", install)
installBtn.addEventListener("click", install)*/
})

9 changes: 7 additions & 2 deletions extension/src/steps/remove-recommend-chrome.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export const removeRecommendChrome = () => {
document.getElementsByClassName("yD5gtd")[0]?.remove()
export const removeRecommendChrome = (store) => {
const targetElem = document.querySelectorAll('[aria-labelledby="promo-header"]')[0]

if (!store.removedRecommendChrome && targetElem) {
store.removedRecommendChrome = true
targetElem.remove()
}
}
5 changes: 3 additions & 2 deletions extension/src/steps/wait-webstore-loaded.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* @returns Promise
*/
export const waitWebstoreLoaded = () => new Promise((resolve) => {
const intervalId = setInterval(() => {
resolve()
/*onst intervalId = setInterval(() => {
if (document.getElementsByClassName("e-f-w-Va").length !== 0) {
clearInterval(intervalId)
resolve()
}
}, 100)
}, 100)*/
})

0 comments on commit daad302

Please sign in to comment.