EpisoQブックマークレット
EpisoPass問題を記述したページでこのブックマークレットを呼び出すとEpisoQが動きます privateなページでも同様
code:episoq.js
javascript:(function(){
var nquestions = 10;
var project = scrapbox.Project.name;
var page = scrapbox.Page.title;
function loadScript (url) {
return new Promise((resolve) => {
const script = document.createElement('script');
script.src = url;
script.onload = resolve;
document.body.appendChild(script);
});
}
async function openEpisoPassWindow(){
if(qa.nquestions){
nquestions = qa.nquestions;
}
questions = qa.questions;
n = questions.length;
while (n) {
const i = Math.floor(Math.random() * n--);
[questionsi, questionsn] = [questionsn, questionsi]; }
window.location.href = http://EpisoPass.com/episopass.html?questions=${qa.questions.slice(0,nquestions).join(';')}&answers=${qa.answers.join(';')};
}
async function episoQ (url) {
await loadScript(url);
await openEpisoPassWindow();
}
for(var line of scrapbox.Page.lines){
var m = line.text.match(/^code:(.*)$/);
if(m){
url = https://scrapbox.io/api/code/${project}/${page}/${script};
episoQ(url);
}
}
})();