initial
This commit is contained in:
commit
94e01d06ff
8 changed files with 174 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
58
app.js
Normal file
58
app.js
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
try {
|
||||||
|
// console.log("fail?")
|
||||||
|
// import $ from jquery
|
||||||
|
const agoraBase = "https://anagora.org/node/"
|
||||||
|
// console.log("agora", agoraBase)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const replaceStrings = (str) => {
|
||||||
|
const wikireg = /\[\[(.*?)\]\]/g
|
||||||
|
const out = str.matchAll(wikireg)
|
||||||
|
|
||||||
|
for (const rep of out) {
|
||||||
|
const slug = rep[1]
|
||||||
|
const wiki = rep[0]
|
||||||
|
const f = slug.toLowerCase().replace(" ", "-")
|
||||||
|
str = str.replace(wiki, `<a href='${agoraBase}${f}'>${wiki}</a>`)
|
||||||
|
}
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(replaceStrings(text))
|
||||||
|
|
||||||
|
|
||||||
|
// const parsePage = () => {
|
||||||
|
// let i = document.body.innerHTML
|
||||||
|
// i = "what the [[fuck]] is this"
|
||||||
|
// const parsed = replaceStrings(i)
|
||||||
|
// // console.log(parsed)
|
||||||
|
// // document.body.innerHTML = parsed
|
||||||
|
// // console.log(i)
|
||||||
|
// // setTimeout(()=>{ $('body').html(parsed)}, 3000)
|
||||||
|
// // $('body').html(parsed);
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
console.log("load script")
|
||||||
|
const foo = $(":not(:has(*))").filter(function () {
|
||||||
|
const txt = $(this).text()
|
||||||
|
const wikireg = /\[\[(.*?)\]\]/g
|
||||||
|
const match = wikireg.test(txt)
|
||||||
|
if (!match) return
|
||||||
|
// if (txt.length > 500) return
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
for (const m of foo) {
|
||||||
|
let t = $(m).text()
|
||||||
|
const txt = replaceStrings(t)
|
||||||
|
$(m).html(txt)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}, 1000)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
0
assets
Normal file
0
assets
Normal file
1
index.html
Normal file
1
index.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
This is a test of [[agora]] linking
|
2
jquery.js
vendored
Normal file
2
jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
21
manifest.json
Normal file
21
manifest.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
|
||||||
|
"manifest_version": 2,
|
||||||
|
"name": "Agora",
|
||||||
|
"version": "1.0",
|
||||||
|
|
||||||
|
"description": "Replaces wiki style links with link to agora",
|
||||||
|
|
||||||
|
"icons": {
|
||||||
|
"48": "icons/border-48.png"
|
||||||
|
},
|
||||||
|
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": ["<all_urls>"],
|
||||||
|
"js": ["jquery.js", "app.js"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
}
|
7
package.json
Normal file
7
package.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"jquery": "^3.5.1",
|
||||||
|
"markdown-it": "^12.0.4",
|
||||||
|
"markdown-it-wikilinks": "^1.0.1"
|
||||||
|
}
|
||||||
|
}
|
84
yarn.lock
Normal file
84
yarn.lock
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
argparse@^2.0.1:
|
||||||
|
version "2.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
|
||||||
|
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
|
||||||
|
|
||||||
|
entities@~2.1.0:
|
||||||
|
version "2.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5"
|
||||||
|
integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==
|
||||||
|
|
||||||
|
extend@^3.0.0:
|
||||||
|
version "3.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa"
|
||||||
|
integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==
|
||||||
|
|
||||||
|
jquery@^3.5.1:
|
||||||
|
version "3.5.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
|
||||||
|
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==
|
||||||
|
|
||||||
|
linkify-it@^3.0.1:
|
||||||
|
version "3.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.2.tgz#f55eeb8bc1d3ae754049e124ab3bb56d97797fb8"
|
||||||
|
integrity sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ==
|
||||||
|
dependencies:
|
||||||
|
uc.micro "^1.0.1"
|
||||||
|
|
||||||
|
markdown-it-regexp@^0.4.0:
|
||||||
|
version "0.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdown-it-regexp/-/markdown-it-regexp-0.4.0.tgz#d64d713eecec55ce4cfdeb321750ecc099e2c2dc"
|
||||||
|
integrity sha1-1k1xPuzsVc5M/esyF1DswJniwtw=
|
||||||
|
|
||||||
|
markdown-it-wikilinks@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdown-it-wikilinks/-/markdown-it-wikilinks-1.0.1.tgz#fb5e0c0a217997b089b8c2dc22f5c572e64aad74"
|
||||||
|
integrity sha1-+14MCiF5l7CJuMLcIvXFcuZKrXQ=
|
||||||
|
dependencies:
|
||||||
|
extend "^3.0.0"
|
||||||
|
markdown-it-regexp "^0.4.0"
|
||||||
|
sanitize-filename "^1.6.1"
|
||||||
|
|
||||||
|
markdown-it@^12.0.4:
|
||||||
|
version "12.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-12.0.4.tgz#eec8247d296327eac3ba9746bdeec9cfcc751e33"
|
||||||
|
integrity sha512-34RwOXZT8kyuOJy25oJNJoulO8L0bTHYWXcdZBYZqFnjIy3NgjeoM3FmPXIOFQ26/lSHYMr8oc62B6adxXcb3Q==
|
||||||
|
dependencies:
|
||||||
|
argparse "^2.0.1"
|
||||||
|
entities "~2.1.0"
|
||||||
|
linkify-it "^3.0.1"
|
||||||
|
mdurl "^1.0.1"
|
||||||
|
uc.micro "^1.0.5"
|
||||||
|
|
||||||
|
mdurl@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
|
||||||
|
integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=
|
||||||
|
|
||||||
|
sanitize-filename@^1.6.1:
|
||||||
|
version "1.6.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/sanitize-filename/-/sanitize-filename-1.6.3.tgz#755ebd752045931977e30b2025d340d7c9090378"
|
||||||
|
integrity sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==
|
||||||
|
dependencies:
|
||||||
|
truncate-utf8-bytes "^1.0.0"
|
||||||
|
|
||||||
|
truncate-utf8-bytes@^1.0.0:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz#405923909592d56f78a5818434b0b78489ca5f2b"
|
||||||
|
integrity sha1-QFkjkJWS1W94pYGENLC3hInKXys=
|
||||||
|
dependencies:
|
||||||
|
utf8-byte-length "^1.0.1"
|
||||||
|
|
||||||
|
uc.micro@^1.0.1, uc.micro@^1.0.5:
|
||||||
|
version "1.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
|
||||||
|
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
|
||||||
|
|
||||||
|
utf8-byte-length@^1.0.1:
|
||||||
|
version "1.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz#f45f150c4c66eee968186505ab93fcbb8ad6bf61"
|
||||||
|
integrity sha1-9F8VDExm7uloGGUFq5P8u4rWv2E=
|
Loading…
Reference in a new issue