parent
1a7d351e95
commit
7dfc65547c
@ -1,2 +1,4 @@
|
|||||||
/tools/chromium_extension/_metadata
|
/tools/chromium_extension/_metadata
|
||||||
|
/tools/chromium_extension/node_modules
|
||||||
|
/tools/chromium_extension/package-lock.json
|
||||||
/.idea
|
/.idea
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
{
|
{
|
||||||
|
let URLObj = new URL(location.href);
|
||||||
|
console.log(URLObj);
|
||||||
|
if (document.querySelector("#readme table tbody")) {
|
||||||
|
let audio_player = new Audio();
|
||||||
|
audio_player.setAttribute("autoplay", "true");
|
||||||
|
document
|
||||||
|
.querySelector("#readme table tbody")
|
||||||
|
.addEventListener("click", (event) => {
|
||||||
|
// console.log(event)
|
||||||
|
// console.log(event.target.nodeType)
|
||||||
|
console.log(event.target.nodeName);
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
let URLObj = new URL(location.href)
|
let audio_url = null;
|
||||||
console.log(URLObj)
|
if (event.target.nodeName === "TD") {
|
||||||
if( document.querySelector("#readme table tbody")) {
|
let aTag = event.target.querySelector("a");
|
||||||
|
if (aTag) {
|
||||||
let audio_player = new Audio()
|
audio_url = aTag.getAttribute("href");
|
||||||
audio_player.setAttribute('autoplay', 'true')
|
}
|
||||||
document.querySelector("#readme table tbody").addEventListener('click', (event) => {
|
}
|
||||||
// console.log(event)
|
if (event.target.nodeName === "IMG") {
|
||||||
// console.log(event.target.nodeType)
|
let aTag = event.target.parentNode.parentNode;
|
||||||
console.log(event.target.nodeName)
|
audio_url = aTag.getAttribute("href");
|
||||||
event.preventDefault();
|
}
|
||||||
event.stopPropagation();
|
if (audio_url) {
|
||||||
|
console.log("audio_url:", audio_url);
|
||||||
let audio_url = null;
|
audio_player.setAttribute("src", audio_url);
|
||||||
if (event.target.nodeName === 'TD') {
|
}
|
||||||
let aTag = event.target.querySelector('a');
|
});
|
||||||
if (aTag) {
|
}
|
||||||
audio_url = aTag.getAttribute('href');
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if (event.target.nodeName === 'IMG') {
|
|
||||||
let aTag = event.target.parentNode.parentNode
|
|
||||||
audio_url = aTag.getAttribute('href');
|
|
||||||
}
|
|
||||||
if (audio_url) {
|
|
||||||
console.log("audio_url:", audio_url)
|
|
||||||
audio_player.setAttribute('src', audio_url);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,34 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "chinese-programmer-wrong-pronunciation-chromium-extension",
|
"name": "chinese-programmer-wrong-pronunciation-chromium-extension",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"description": "README.md 页面无跳转 即可听正确读音",
|
"description": "README.md 页面无跳转 即可听正确读音",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": [
|
"matches": ["*://*/shimohq/chinese-programmer-wrong-pronunciation/*"],
|
||||||
"*://*/shimohq/chinese-programmer-wrong-pronunciation/*"
|
"run_at": "document_end",
|
||||||
],
|
"js": ["js/content-script.js"]
|
||||||
"run_at": "document_end",
|
}
|
||||||
"js": ["js/content-script.js"]
|
],
|
||||||
}
|
"permissions": [
|
||||||
],
|
"declarativeNetRequest",
|
||||||
"permissions": [
|
"declarativeNetRequestWithHostAccess"
|
||||||
"declarativeNetRequest",
|
],
|
||||||
"declarativeNetRequestWithHostAccess"
|
"host_permissions": ["*://github.com/*", "*://localhost:*/*"],
|
||||||
],
|
"declarative_net_request": {
|
||||||
"host_permissions": [
|
"rule_resources": [
|
||||||
"*://github.com/*",
|
{
|
||||||
"*://localhost:*/*"
|
"id": "remove_content_security_policy",
|
||||||
],
|
"enabled": true,
|
||||||
"declarative_net_request" : {
|
"path": "rules/remove_content_security_policy.json"
|
||||||
"rule_resources" : [
|
}
|
||||||
{
|
]
|
||||||
"id": "remove_content_security_policy",
|
},
|
||||||
"enabled": true,
|
"author": "https://github.com/jingjingxyk",
|
||||||
"path": "rules/remove_content_security_policy.json"
|
"homepage_url": "https://github.com/shimohq/chinese-programmer-wrong-pronunciation.git"
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
|
||||||
"author": "https://github.com/jingjingxyk",
|
|
||||||
"homepage_url": "https://github.com/shimohq/chinese-programmer-wrong-pronunciation.git"
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "chinese-programmer-wrong-pronunciation-chromium-extension",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "README.md 页面无跳转 即可听正确读音",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"format-code": "npx prettier --write . && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "2.6.2"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue