move standalone projects into own directory

This commit is contained in:
2023-04-27 11:39:41 -06:00
parent 5d593e22b0
commit acda704057
369 changed files with 1170 additions and 5 deletions

View File

@@ -0,0 +1,4 @@
bin/
libs/
node_modules/
*.zip

View File

@@ -0,0 +1,12 @@
-lib kiss
-lib kiss-firefox
-lib webextension-polyfill
-cp src
-dce full
--each
--main tig_spy.Main
--js bin/main.js
--next
--main tig_spy.Background
--js bin/background.js
-cmd cp node_modules/webextension-polyfill/dist/browser-polyfill.js* bin/ && zip -r template.zip . -x *.git* -x *.hxml -x *.zip -x src/\* -x node_modules/\* -x libs/\* -x test.sh

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

View File

@@ -0,0 +1,30 @@
{
"name": "tig-spy",
"description": "analytics for TIGForum dev logs",
"icons": {
"48": "icons/icon-48.png"
},
"background": {
"scripts": [
"bin/browser-polyfill.js",
"bin/background.js"
]
},
"content_scripts": [
{
"js": [
"bin/browser-polyfill.js",
"bin/main.js"
],
"matches": [
"*://forums.tigsource.com/index.php?topic=*"
]
}
],
"permissions": [
"<all_urls>",
"tabs"
],
"version": "0.0",
"manifest_version": 2
}

View File

@@ -0,0 +1,82 @@
{
"name": "tig-spy",
"version": "0.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "tig-spy",
"version": "0.0.0",
"hasInstallScript": true,
"dependencies": {
"@types/webextension-polyfill": "^0.10.0",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
"dts2hx": "^0.19.0"
}
},
"node_modules/@types/webextension-polyfill": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",
"integrity": "sha512-If4EcaHzYTqcbNMp/FdReVdRmLL/Te42ivnJII551bYjhX19bWem5m14FERCqdJA732OloGuxCRvLBvcMGsn4A=="
},
"node_modules/dts2hx": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/dts2hx/-/dts2hx-0.19.2.tgz",
"integrity": "sha512-1+X3kOB941APt/O6b5jX9+XMefRPqvFk4fvGDHPLIbuYdIAjNwcX3XOuZJ9fYtUD7Odn4ACPfK2ql2HWaFrLrg==",
"dev": true,
"dependencies": {
"typescript": "3.7.4"
},
"bin": {
"dts2hx": "cli.js"
}
},
"node_modules/typescript": {
"version": "3.7.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz",
"integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/webextension-polyfill": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",
"integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g=="
}
},
"dependencies": {
"@types/webextension-polyfill": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",
"integrity": "sha512-If4EcaHzYTqcbNMp/FdReVdRmLL/Te42ivnJII551bYjhX19bWem5m14FERCqdJA732OloGuxCRvLBvcMGsn4A=="
},
"dts2hx": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/dts2hx/-/dts2hx-0.19.2.tgz",
"integrity": "sha512-1+X3kOB941APt/O6b5jX9+XMefRPqvFk4fvGDHPLIbuYdIAjNwcX3XOuZJ9fYtUD7Odn4ACPfK2ql2HWaFrLrg==",
"dev": true,
"requires": {
"typescript": "3.7.4"
}
},
"typescript": {
"version": "3.7.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz",
"integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==",
"dev": true
},
"webextension-polyfill": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",
"integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g=="
}
}
}

View File

@@ -0,0 +1,16 @@
{
"main": "index.js",
"name": "tig-spy",
"description": "analytics for TIGForum dev logs",
"dependencies": {
"@types/webextension-polyfill": "^0.10.0",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
"dts2hx": "^0.19.0"
},
"version": "0.0.0",
"scripts": {
"postinstall": "dts2hx --all"
}
}

View File

@@ -0,0 +1,9 @@
package tig_spy;
import kiss.Prelude;
import kiss_firefox.API;
import haxe.Constraints;
import tig_spy.Message;
@:build(kiss.Kiss.build())
class Background {}

View File

@@ -0,0 +1,22 @@
(var &mut :Array<String> collectedAuthors [])
(var &mut :Array<String> pages [])
(function sendNextPage [:Function sendResponse]
(awaitLet [tabs (API.browser.tabs.query (object active true))
&sync id .id (first tabs)]
(if pages
(API.browser.tabs.sendMessage id (object type "nextPage" data [(pages.shift)]))
(API.browser.tabs.sendMessage id (object type "authorList" data collectedAuthors)))))
(API.browser.runtime.onMessage.addListener ->[:Message message sender sendResponse]
(let [:Function sendResponse sendResponse]
(case message
((object type "authors" data authors)
(set collectedAuthors (collectedAuthors.concat authors))
(sendNextPage sendResponse))
((object type "pages" data pageUrls)
(set collectedAuthors [])
(set pages pageUrls)
(sendResponse ""))
(never otherwise))
true))

View File

@@ -0,0 +1,7 @@
package tig_spy;
class Main {
static function main() {
Main_.main();
}
}

View File

@@ -0,0 +1,96 @@
(import kiss_firefox.API)
(import js.lib.Promise)
(import tig_spy.Message)
(var :Dynamic document js.Lib.global.document)
(var :Dynamic window js.Lib.global.window)
(function p [text]
(let [element (document.createElement "p")]
(set element.innerHTML text)
element))
(let [analyticsDiv (document.createElement "div")]
(document.body.prepend analyticsDiv)
(set Prelude.printStr ->s (analyticsDiv.appendChild (p s))))
(function postElements [:Dynamic document]
(let [postTable (.item (document.getElementsByClassName "bordercolor") 0)
postTableBody (postTable.children.item 0)
tableRows (for i (range postTableBody.children.length) (postTableBody.children.item i))]
// There is an empty row at the end:
(tableRows.pop)
tableRows))
(function postAuthors [:Dynamic document]
(API.browser.runtime.sendMessage
(object
type "authors"
data
(for [idx post] (enumerate (postElements document))
(let [links (post.getElementsByTagName "a")
userLink (links.item (min idx 1))]
userLink.innerHTML)))))
(function printPostStats [:Array<String> authors]
(let [:String subjectLine .innerHTML (document.getElementById "top_subject")
lastLeftParenIndex (subjectLine.lastIndexOf "(")
lastRightParenIndex (subjectLine.lastIndexOf ")")
[Read n times] (.split (substr subjectLine lastLeftParenIndex lastRightParenIndex) " ")]
(print "$n views"))
(let [op (first authors)
:Map<String,Bool> repliers (new Map)
&mut updates 0
&mut replies 0]
(doFor author authors
(cond
((= op author)
(+= updates 1))
(true
(dictSet repliers author true)
(+= replies 1))))
(print "$updates updates by OP")
(print "$replies replies by $(count repliers) followers")))
(cond
((StringTools.endsWith window.location.href ".0")
(let [analyticsLink (document.createElement "a")]
(analyticsLink.addEventListener "click"
->:Void {
(let [:String url
window.location.href
urlWithoutStartingPost0
(substr url 0 -1)
postsPerPage
20
navPageElements
(document.getElementsByClassName "navPages")
numPages
(if (< 0 navPageElements.length)
(Std.parseInt .innerHTML (nth navPageElements (- navPageElements.length 1)))
1)]
(awaitLet [_
(API.browser.runtime.sendMessage
(object
type "pages"
data (for page (range 1 numPages) "${urlWithoutStartingPost0}$(* page postsPerPage)")))]
(postAuthors document)))
})
(set analyticsLink.innerHTML "Run analytics")
(document.body.prepend analyticsLink)))
(true
(window.addEventListener "load"
->:Void (postAuthors document))))
(API.browser.runtime.onMessage.addListener
->[:Message message sender sendResponse] {
(case message
((object type "nextPage" data [pageUrl])
(set window.location.href pageUrl))
((object type "authorList" data authors)
(printPostStats authors))
(never otherwise))
true
})

View File

@@ -0,0 +1,6 @@
package tig_spy;
typedef Message = {
type:String,
data:Array<String>
};

View File

@@ -0,0 +1,7 @@
#! /bin/bash
if [ ! -d node_modules ]; then
$(haxelib libpath kiss)/build-scripts/dts2hx-externs/regenerate.sh
fi
haxe -D test build.hxml