Premier commit

This commit is contained in:
Boris 2023-01-26 22:02:25 +01:00
parent a5f8854c26
commit 1a59a163ca
14 changed files with 487 additions and 0 deletions

19
funiter-answer.js.js Normal file
View File

@ -0,0 +1,19 @@
let answerButtonWrapper = document.createElement('nav')
answerButtonWrapper.style.position = 'fixed'
answerButtonWrapper.style.bottom = '0'
answerButtonWrapper.style.width = '100%'
answerButtonWrapper.style.zIndex = '666'
answerButtonWrapper.style.textAlign = 'center'
let answerButton = document.createElement('button')
answerButton.innerHTML = 'Répondre'
answerButton.classList.add("btn-primary", "btn", "btn-icon-text")
answerButtonWrapper.append(answerButton)
document.body.append(answerButtonWrapper)
answerButton.addEventListener('click', function () {
alert('coucou')
})

252
funiter.js Normal file
View File

@ -0,0 +1,252 @@
const gateway = 'gateway.pinata.cloud';
// const gateway = 'ipfs.copylaradio.com';
// const gateway = 'libra.copylaradio.com';
const answersId = 'Qmde15Aqjvz59s38ma3UhGTbKnwJtS5wYDwKRuQQrrc7mD';
let feedUrl = 'http://' + gateway + '/ipfs/' + answersId;
// let url = 'ipfs:///ipfs/' + answersId;
let jsToDOM = function (rootElt, children) {
for (const child of children) {
let elt = document.createElement(child.tag)
if (child.classList !== undefined) {
for (const aCSSClass of child.classList) {
elt.classList.add(aCSSClass)
}
}
if (child.props !== undefined) {
for (const property in child.props) {
elt[property] = child.props[property]
}
}
if (child.children !== undefined) {
elt = jsToDOM(elt, child.children)
} else {
if (child.innerHTML !== undefined) {
elt.innerHTML = child.innerHTML
}
}
rootElt.append(elt)
}
return rootElt
}
let vaChercher = async function (pageUrl) {
var myHeaders = new Headers();
let options = {
method: 'GET', // *GET, POST, PUT, DELETE, etc.
// mode: 'no-cors', // no-cors, *cors, same-origin
cache: 'default', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'omit', // include, *same-origin, omit
// headers: myHeaders,
headers: { "Content-Type": "application/json" },
redirect: 'follow', // manual, *follow, error
referrerPolicy: 'no-referrer' // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
};
// console.log(url);
fetch(feedUrl, options)
.then(r => {
if (!r.ok) {
throw new Error('Network response was not OK');
}
return r.json()
})
.then(jason => {
for (const item of jason) {
let whereChild = document.querySelector('[data-post-id="'+item.position+'"]')
let where = whereChild.parentNode
let message = {
author : 'boris'
, relativeDate : '2022-12-27'
, contents : item.message
, userAvatarSrc : browser.runtime.getURL("icons/tails.png")
}
let freeUserSymbol = browser.runtime.getURL("icons/funiter-48.png")
let messageWrapperElt = document.createElement("div")
messageWrapperElt.classList.add("topic-post", "clearfix", "regular", "sticky-avatar")
let template = [
{
tag : 'article'
, classList : ['boxed', 'onscreen-post']
, children : [
{
tag : 'div'
, classList : ['row']
, children : [
{
tag : 'div'
, classList : ['topic-avatar']
, children : [
{
tag : 'div'
, classList : ['post-avatar']
, children : [
{
tag : 'a'
, classList : ['trigger-user-card', 'main-avatar']
, children : [
{
tag : 'img'
, classList : ['avatar']
, props : {
src : message.userAvatarSrc
, width : 45
, height : 45
}
}
]
}
]
}
]
}
, {
tag : 'div'
, classList : ['topic-body', 'clearfix']
, children : [
{
tag : 'div'
, classList : ['topic-meta-data']
, children : [
{
tag : 'div'
, classList : ['names', 'trigger-user-card']
, children : [
{
tag : 'span'
, classList : ['first', 'username']
, children : [
{
tag : 'a'
, innerHTML : message.author
}
, {
tag : 'span'
, classList : ['svg-icon-title']
, props : {
title : 'This user is free'
}, children : [
{
tag : 'img'
, props : {
width : 16
, height : 16
, src : freeUserSymbol
}
}
]
}
]
}
]
}
, {
tag : 'div'
, classList : ['post-infos']
, children : [
{
tag : 'div'
, classList : ['post-info', 'post-date']
, children : [
{
tag : 'a'
, classList : ['widget-link', 'post-date']
, children : [
{
tag : 'span'
, classList : ['relative-date']
, innerHTML : message.relativeDate
}
]
}
]
}
]
}
]
}
, {
tag : 'div'
, classList : ['regular', 'contents']
, children : [
{
tag : 'div'
, classList : 'cooked'
, innerHTML : message.contents
}
]
}
]
}
]
}
]
}
]
messageWrapperElt = jsToDOM(messageWrapperElt, template)
where.insertAdjacentElement('afterend', messageWrapperElt)
}
})
.catch(err => {
console.error(err)
})
}
let pageUrl = window.location.href
if (pageUrl.match(/\/[0-9]+(\/[0-9]+)?$/)) {
vaChercher(pageUrl)
}
let tabUpdateHandler = function () {
/*
console.log("j'écoute")
*/
}
console.log('coucou')
// DOMContentLoaded
document.addEventListener('DOMContentLoaded', (event) => {
console.log('coucou 2')
tabUpdateHandler()
})

BIN
icons/funiter-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

BIN
icons/funiter-48.xcf Normal file

Binary file not shown.

BIN
icons/tails.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

38
index.html Normal file
View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<title>Funiter</title>
<meta charset="utf-8" />
</head>
<body>
<h1>Funiter</h1>
<div>
<article id="post_1">
<p>
Post 1
</p>
</article>
</div>
<div>
<article id="post_2">
<p>
Post 2
</p>
</article>
</div>
<div>
<article id="post_3">
<p>
Post 3
</p>
</article>
</div>
<!--<script type="text/javascript" src="./funiter.js"></script>-->
</body>
</html>

7
intentions.md Normal file
View File

@ -0,0 +1,7 @@
- index.html de feed de tout ce que j'ai publié partout
- passer en IPNS
- interface de paramétrage des gens suivis (comme pour LightBeams)

29
manifest.json Normal file
View File

@ -0,0 +1,29 @@
{
"manifest_version": 2
,"name": "Funiter - Chevaucher le cochon"
,"version": "1.0"
,"description": "Funiter, qui est le diminutif de “Freedom uniter”, ou « distributeur de liberté » en bon françois, est un plugin Firefox qui sert à afficher sur l'instance du logiciel Discourse installé à forum.duniter.org les messages publiés par quelques gens qui n'aiment ni être bâillonné, ni voir leurs écrits travestis sans leur permission. Lesdits messages sont accédés via des passerelles IPFS. Merci à vit et Hugo de m'avoir motivé à créer ce plugin."
,"icons": {
"48": "icons/funiter-48.png"
}
,"content_scripts": [
{
"matches": ["*://forum.duniter.org/*", "*://funiter/*"],
"js": ["funiter.js"]
}
]
,"permissions": [
"*://libra.copylaradio.com/*",
"*://gateway.pinata.cloud/*"
]
,"web_accessible_resources": [
"icons/funiter-48.png"
]
}

22
tests/boris_feeds.json Normal file
View File

@ -0,0 +1,22 @@
{
"pseudo" : "boris"
, "avatar" : ""
, "feeds" : [
{
"url" : "forum.duniter.org"
, "feed" : "ipfs:///ipfs/Qmde15Aqjvz59s38ma3UhGTbKnwJtS5wYDwKRuQQrrc7mD"
}
,{
"url" : "forum.monnaie-libre.org"
, "feed" : "ipfs:///ipns/..."
}
,{
"url" : "community.snowdrift.coop"
, "feed" : "ipfs:///ipns/..."
}
,{
"url" : "talk.tiddlywiki.org"
, "feed" : "ipfs:///ipns/..."
}
]
}

7
tests/data.json Normal file
View File

@ -0,0 +1,7 @@
[
{
"position": "87603",
"message": "Eh, merde, tu es tombé dedans aussi ^^"
}
]

View File

@ -0,0 +1,6 @@
[
{
"id" : "9424"
, "feed" : "ipfs:///ipfs/Qmde15Aqjvz59s38ma3UhGTbKnwJtS5wYDwKRuQQrrc7mD"
}
]

37
tests/post.html Normal file
View File

@ -0,0 +1,37 @@
<div class="topic-post clearfix regular" id="" style="min-height: 240.8px">
<article id="post_26" aria-label="post #26 by @poka" role="region" data-post-id="81616" data-topic-id="9424" data-user-id="257" class="boxed onscreen-post"><span aria-hidden="true" tabindex="-1" class="tabLoc"></span>
<div class="row">
<div class="topic-avatar">
<div class="post-avatar">
<a class="trigger-user-card main-avatar " href="/u/poka" data-user-card="poka" aria-hidden="true" tabindex="-1"><img alt="" src="/user_avatar/forum.duniter.org/poka/45/6827_2.png" loading="lazy" class="avatar" width="45" height="45"></a>
</div>
</div>
<div class="topic-body clearfix">
<div role="heading" aria-level="2" class="topic-meta-data">
<div class="names trigger-user-card"><span class="first username staff admin moderator"><a href="/u/poka" data-user-card="poka" class="">poka</a><span title="This user is a moderator" class="svg-icon-title"><svg class="fa d-icon d-icon-shield-alt svg-icon svg-node" aria-hidden="true"><use xlink:href="#shield-alt"></use></svg></span></span>
</div>
<div class="post-infos">
<div class="post-info post-date"><a class="widget-link post-date" href="/t/logo-duniter-v2/9424/26" title="Post date"><span title="11 Jun 2022 00:54" data-time="1654901676427" data-format="tiny" class="relative-date">11 Jun</span></a></div>
<div class="read-state read" title="Post is unread"><svg class="fa d-icon d-icon-circle svg-icon svg-node" aria-hidden="true"><use xlink:href="#circle"></use></svg></div>
</div>
</div>
<div class="regular contents">
<div class="cooked">
<p>moi je touche pas aux images, chacun son truc <img src="https://forum.duniter.org/images/emoji/twitter/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" style="aspect-ratio: 20 / 20;" width="20" height="20"></p>
<hr>
<p>Je trouve ça beaucoup mieux comme ça, il reste toute la partie gauche où on peut ajouter ce quon veut, toujours discret bien sûr, mais je sais pas quoi. un D pour duniter, mais bon …</p>
</div>
<section class="post-menu-area clearfix">
<nav class="post-controls expanded">
<div class="actions">
<div class="double-button"><button class="widget-button btn-flat button-count like-count highlight-action regular-likes btn-icon-text" title="2 people liked this post" aria-label="2 people liked this post. Click to view" aria-pressed="false">2<svg class="fa d-icon d-icon-d-unliked svg-icon svg-node" aria-hidden="true"><use xlink:href="#far-heart"></use></svg></button></div><button class="widget-button btn-flat share no-text btn-icon" title="share a link to this post"><svg class="fa d-icon d-icon-d-post-share svg-icon svg-node" aria-hidden="true"><use xlink:href="#link"></use></svg></button></div>
</nav>
</section>
</div>
<section class="post-actions">
</section>
<div class="post-links-container"></div>
</div>
</div>
</article>
</div>

70
tests/post2.html Normal file
View File

@ -0,0 +1,70 @@
<div class="topic-avatar">
<div class="post-avatar">
<a class="trigger-user-card main-avatar " href="/u/poka" data-user-card="poka" aria-hidden="true" tabindex="-1">
<img alt="" src="/user_avatar/forum.duniter.org/poka/45/6827_2.png" loading="lazy" class="avatar" width="45" height="45">
</a>
</div>
</div>
<div class="topic-body clearfix">
<div role="heading" aria-level="2" class="topic-meta-data">
<div class="names trigger-user-card">
<span class="first username staff admin moderator">
<a href="/u/poka" data-user-card="poka" class="">poka</a>
<span title="This user is a moderator" class="svg-icon-title">
<svg class="fa d-icon d-icon-shield-alt svg-icon svg-node" aria-hidden="true"><use xlink:href="#shield-alt"></use></svg>
</span>
</span>
</div>
<div class="post-infos">
<div class="post-info post-date">
<a class="widget-link post-date" href="/t/logo-duniter-v2/9424/26" title="Post date">
<span title="11 Jun 2022 00:54" data-time="1654901676427" data-format="tiny" class="relative-date">
11 Jun
</span>
</a>
</div>
<div class="read-state read" title="Post is unread">
<svg class="fa d-icon d-icon-circle svg-icon svg-node" aria-hidden="true">
<use xlink:href="#circle"></use>
</svg>
</div>
</div>
</div>
<div class="regular contents">
<div class="cooked">
<p>moi je touche pas aux images, chacun son truc <img src="https://forum.duniter.org/images/emoji/twitter/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" style="aspect-ratio: 20 / 20;" width="20" height="20"></p>
<hr>
<p>Je trouve ça beaucoup mieux comme ça, il reste toute la partie gauche où on peut ajouter ce quon veut, toujours discret bien sûr, mais je sais pas quoi. un D pour duniter, mais bon …</p>
</div>
<section class="post-menu-area clearfix">
<nav class="post-controls expanded">
<div class="actions">
<div class="double-button">
<button class="widget-button btn-flat button-count like-count highlight-action regular-likes btn-icon-text" title="2 people liked this post" aria-label="2 people liked this post. Click to view" aria-pressed="false">2
<svg class="fa d-icon d-icon-d-unliked svg-icon svg-node" aria-hidden="true">
<use xlink:href="#far-heart"></use>
</svg>
</button>
</div>
<button class="widget-button btn-flat share no-text btn-icon" title="share a link to this post">
<svg class="fa d-icon d-icon-d-post-share svg-icon svg-node" aria-hidden="true">
<use xlink:href="#link"></use>
</svg>
</button>
</div>
</nav>
</section>
</div>
<section class="post-actions">
</section>
<div class="post-links-container"></div>
</div>

BIN
tests/tails.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB