start
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1,95 @@
|
||||
// update the version number in manifest in order to be able to reload via Firefox itself
|
||||
console.log('extension loaded kbd');
|
||||
document.addEventListener("keypress", function(event) {
|
||||
console.log('pressed ' + event.key);
|
||||
if (event.key == 'r') {
|
||||
window.location.reload()
|
||||
}
|
||||
if (event.key == 'x') {
|
||||
autoscroll()
|
||||
}
|
||||
if (event.key == 'b') {
|
||||
history.back()
|
||||
}
|
||||
if (event.key == 'a') {
|
||||
addWiki()
|
||||
}
|
||||
if (event.key == 'r') {
|
||||
window.location.reload()
|
||||
}
|
||||
if (event.key == 'h') {
|
||||
alert('r to reload, h for help, etc')
|
||||
}
|
||||
})
|
||||
|
||||
// from https://gist.github.com/Utopiah/525718c8a60ee2d9e25d7724e9dbb355
|
||||
const month = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ][new Date().getMonth()];
|
||||
const year = new Date().getFullYear();
|
||||
const url = `https://fabien.benetou.fr/PersonalInformationStream/WithoutNotes${month}${year}`;
|
||||
|
||||
function addWiki(){
|
||||
fetch(url+'?action=source') .then( response => { return response.text() } ) .then( data => {
|
||||
var writeURL = url + '?action=edit';
|
||||
var selection = window.getSelection().toString();
|
||||
var content = "post=1&author=PIM_Trydactil&authpw=edit_password&text="+data+'%0a* '
|
||||
+ window.location.href.replace(/\?utm_source.*/,'');
|
||||
if (selection) content += '%0a** ' + selection;
|
||||
fetch(writeURL, { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: content })
|
||||
.then(res => res).then(res => {
|
||||
var div = document.createElement("div");
|
||||
div.innerText = "Status adding URL to PIM : " + res.status;
|
||||
div.onclick = _ => window.open(url);
|
||||
div.style = "position:absolute; top:100px; left:100px; z-index:999; color:red; background-color:yellow;";
|
||||
document.body.appendChild( div ); setTimeout( _ => div.style.display = "none", 2000);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
var as
|
||||
|
||||
function autoscroll(){
|
||||
if (!as) {
|
||||
as = setInterval( () => { window.scrollBy(0, 1) } , 100 );
|
||||
// for a normal page use window.scrollBy instead
|
||||
} else {
|
||||
clearInterval(as); as = null; scrolling = false;
|
||||
}
|
||||
}
|
||||
|
||||
// find event on pointer focused
|
||||
// then chck if input, textarea, and other elements with legit keyboard usage
|
||||
// https://stackoverflow.com/questions/497094/how-do-i-find-out-which-dom-element-has-the-focus
|
||||
// can be tested (on desktop only) via file:///home/fabien/Prototypes/vrify/test.html
|
||||
|
||||
// warnings
|
||||
// file:/// not supported on Android
|
||||
// https://support.mozilla.org/en-US/questions/1415622
|
||||
// done
|
||||
// autoscroll
|
||||
// shortcut to add to PIM
|
||||
|
||||
// can try
|
||||
// autoscroll on dev orientation
|
||||
// shortcuts as data
|
||||
// loaded as defaults
|
||||
// from localStorage as local modifications
|
||||
// from PIM
|
||||
// from specific locations dedicated to a specific usages
|
||||
// auto-reloading once script or data is modified
|
||||
// can regenerate .xpi but unsure how to reload on mobile
|
||||
|
||||
// packaging mechanism (requires unsigned)
|
||||
// vi manifest.json
|
||||
// sed "s/\"version.*/\"version\": \"$(date +%s)\",/" -i manifest.json
|
||||
// broke the whole thing
|
||||
// zip -r0 kbd.xpi manifest.json kbd.js options.html icons/
|
||||
// better than
|
||||
// zip -r0 kbd.xpi *
|
||||
// kdeconnect-cli -n Pixel --share kbd.xpi
|
||||
// could try with inotify
|
||||
|
||||
// 1-liner
|
||||
// sed "s/\"version.*/\"version\": \"$(date +%s)\",/" -i manifest.json ; zip -r0 kbd.xpi manifest.json kbd.js options.html icons/ ; kdeconnect-cli -n Pixel --share kbd.xpi
|
||||
|
||||
// Firefox Nightly can not install .xpi via URL
|
||||
2033 history | tail -2 >> kbd.js
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "keyboard",
|
||||
"version": "1785831306",
|
||||
|
||||
"description": "Adds keyboard capabilities shortuts for content on your local filesystem.",
|
||||
|
||||
"icons": {
|
||||
"48": "icons/border-48.png"
|
||||
},
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["file:///*", "https://fabien.benetou.fr/*"],
|
||||
"js": ["kbd.js"]
|
||||
}
|
||||
],
|
||||
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "{824605d4-e7d3-4e14-961d-9d6a69a666c2}"
|
||||
}
|
||||
},
|
||||
|
||||
"options_ui": {
|
||||
"page": "options.html"
|
||||
},
|
||||
|
||||
"permissions": ["storage"]
|
||||
|
||||
|
||||
|
||||
}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
sed "s/\"version.*/\"version\": \"$(date +%s)\",/" -i manifest.json
|
||||
zip -r0 kbd.xpi manifest.json kbd.js options.html icons/
|
||||
kdeconnect-cli -n Pixel --share kbd.xpi
|
||||
Reference in New Issue
Block a user