外部鯖のアンケートに投票した後で正確な票数を知りたいときにも使える
alertで出ます。
「投票するまで票数を隠す」オプションがオンなら多分出ないと思います。
トゥート個別ページ「https://${domain}/@${acct}/${id}
」に対応。いわゆる「元のページを表示」を押す必要があります。
@${acct}
の代わりにnotice
でもOKです。Pleroma用に用意されています。
bookmarklet.js
の中身をブックマークに登録してください。
javascript: (function(){async function d(){const t=location.href.match(/https:\/\/([^\/]+)\/(@[a-zA-Z0-9_]+|notice)\/([^\/]+)/);if(t){const o=t[1],e=t[3],l=await fetch(`https://${o}/api/v1/statuses/${e}`,{method:"GET",headers:{"content-type":"application/json"}});l.ok||alert("Error");const n=await l.json();if(n.poll){const t=n.poll.options;let o="Results: ";if(null==t[0].votes_count)return alert("This is a result-hidden poll"),!1;for(let e=0;e<t.length;e++)o+=`\n${t[e].title}:${t[e].votes_count}`;alert(o)}else alert("not poll")}}d();}()); |
async function d() { | |
const m = location.href.match(/https:\/\/([^/]+)\/(@[a-zA-Z0-9_]+|notice)\/([^/]+)/) | |
if (m) { | |
const d = m[1] | |
const i = m[3] | |
const u = `https://${d}/api/v1/statuses/${i}` | |
const p = await fetch(u, { | |
method: 'GET', | |
headers: { | |
'content-type': 'application/json' | |
} | |
}) | |
if (!p.ok) { | |
alert('Error') | |
} | |
const j = await p.json() | |
if (j.poll) { | |
const v = j.poll.options | |
let s = 'Results: ' | |
if (v[0].votes_count == null) { | |
alert('This is a result-hidden poll') | |
return false | |
} | |
for (let a = 0; a < v.length; a++) { | |
s+= `\n${v[a].title}:${v[a].votes_count}` | |
} | |
alert(s) | |
} else { | |
alert('not poll') | |
} | |
} | |
} | |
d() |