diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44ce34d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +web-ext-artifacts diff --git a/Screens/posts.png b/Screens/posts.png new file mode 100644 index 0000000..0c56e00 Binary files /dev/null and b/Screens/posts.png differ diff --git a/Screens/setup.png b/Screens/setup.png new file mode 100644 index 0000000..57d03e7 Binary files /dev/null and b/Screens/setup.png differ diff --git a/content_script.js b/content_script.js new file mode 100644 index 0000000..e69de29 diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..91df1ab --- /dev/null +++ b/icon.svg @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + D + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..1490efb --- /dev/null +++ b/manifest.json @@ -0,0 +1,32 @@ +{ + "manifest_version": 2, + "name": "dissent", + "version": "0.1.0", + "content_scripts":[ + { + "matches":["https://*/*"], + "js": ["content_script.js"] + } + ], + "options_ui":{ + "page":"options.html" + }, + "browser_action": { + "browser_style": true, + "default_icon": "/icon.svg", + "default_title": "Misskey Dissenter", + "default_popup": "popup.html" + }, + + "browser_specific_settings":{ + "gecko":{ + "id":"notsure@ifneeded.com" + } + }, + "permissions":[ + "", + "webRequest", + "storage", + "tabs" + ] +} diff --git a/options.html b/options.html new file mode 100644 index 0000000..8cb73b5 --- /dev/null +++ b/options.html @@ -0,0 +1,20 @@ + + + + + + + + + +
+ +

Dissent

+
+
+
+ +
+ + + \ No newline at end of file diff --git a/options.js b/options.js new file mode 100644 index 0000000..ae21c8d --- /dev/null +++ b/options.js @@ -0,0 +1,14 @@ +var instance = document.getElementById('instance') + +instance.addEventListener('onchange',function (event){ + browser.storage.sync.set({'value':event.target.value}); +}); +document.getElementById('save').addEventListener('click',function(event){ + browser.storage.sync.set({'value':instance.value}); +}); + +document.addEventListener('DOMContentLoaded',function(){ + browser.storage.sync.get('value').then( + result => instance.value = result.value, + err => instance.value="Error.") +}); \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..a7cfc3c --- /dev/null +++ b/popup.html @@ -0,0 +1,20 @@ + + + + + + + + + + +

+

Posts:

+
+ +
+ Settings + + + + \ No newline at end of file diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..b66ad77 --- /dev/null +++ b/popup.js @@ -0,0 +1,56 @@ +var misskey_host = "" +err = document.getElementById('err'); +browser.storage.sync.get('value').then( +result => misskey_host = result.value, +err => misskey_host = default_host); + + +browser.storage.sync.get('instance').then(result => misskey_host = instance) +browser.tabs + .query({ currentWindow: true, active: true }) + .then(tabs => update_data(tabs[0].url), err => document.getElementById('err').innerHTML=err); + +function display_notes(data){ + n = document.getElementById('notes'); + n.innerHTML = ""; + update = ""; + if (data.length == 0){ + update="

No data

" + } + for (var i = 0; i < data.length; i++){ + note = data[i]; + if (note['user']['host'] == null){ + note['user']['host'] = misskey_host; + } + update += "
"; + update +="
"; + if (!note['url']){ + note['url'] = note['uri']; + } + update +="

"+note['text']+"
link " + if (note['renoteCount'] || note['repliesCount']){ + update +=note['renoteCount']+" renotes "+note['repliesCount']+" replies" + + } + update += "


" + } + n.innerHTML = update; + document.getElementById('err').style.display="none"; +} + + +async function update_data(url){ + document.getElementById('err').innerHTML = "Getting notes for:" + url +"
From: "+misskey_host; + data = JSON.stringify({ + "query":url, + "limit":100, + + }); + await fetch(misskey_host +"/api/notes/search",{ + method:'POST', + body:data, + headers:{"Content-Type":"application/json"} + }).then(resp => resp.json()).then(data => display_notes(data)); +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..61a74eb --- /dev/null +++ b/style.css @@ -0,0 +1,72 @@ +body { + margin: 0; + padding: 0; + --theme-color-primary: rgba(255, 255, 255, 1); + --theme-color-secondary: black; + --theme-accent: #09448c; + background-color: var(--theme-color-primary); + color: var(--theme-color-secondary); + font-size: 1.5rem; + display:flex; + flex-direction: column; + align-items: center; + padding:2rem; + height:100%; +} +@media screen and (prefers-color-scheme:dark) { + body { + --theme-color-primary: rgba(0, 0, 0, 1); + --theme-color-secondary: white; + --theme-accent: #2db1f3; + } +} +a{ + text-decoration: none; + color:var(--theme-accent); +} +hr{ + width:100%; + color:transparent; +} +#url{ + width:100%; + padding:0.5rem; + border-radius:0.5rem; +} +#notes{ + display:flex; + flex-direction: column; + max-width:1200px; +} + +.note{ + color: var(--theme-color-secondary); + width:100%; + display:flex; + align-items: flex-start; + justify-content: flex-start; + flex-direction: row; + padding-bottom: 1rem; + +} +.poster{ + display:flex; + flex-direction: column-reverse; + align-items: center; + justify-content: flex-start; + width:20rem; + max-width:20rem; + margin:0; + margin-right:1rem; + word-wrap: break-word; + +} +.poster * { + margin:0; +} +.poster img { + width:15rem; +} +.note>*{ + margin:1rem; +} \ No newline at end of file