diff --git a/.gitignore b/.gitignore index 3c3629e..8ab3c7e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +db.* +*.sqlite* node_modules +npm-debug.log diff --git a/db.sqlite b/db.sqlite deleted file mode 100755 index 8472f69..0000000 Binary files a/db.sqlite and /dev/null differ diff --git a/db.sqlite.201701010102 b/db.sqlite.201701010102 deleted file mode 100755 index 3c7eabb..0000000 Binary files a/db.sqlite.201701010102 and /dev/null differ diff --git a/db.sqlite.201701012214 b/db.sqlite.201701012214 deleted file mode 100755 index 9e186af..0000000 Binary files a/db.sqlite.201701012214 and /dev/null differ diff --git a/index.js b/index.js old mode 100755 new mode 100644 index 25e74da..c583b6f --- a/index.js +++ b/index.js @@ -36,7 +36,6 @@ app.get('/', function (req, res) { "LEFT JOIN images AS i ON i.id = q.id " + "ORDER BY T2.id DESC", function (err, rows) { - //console.log('selected rows:', rows.length); if (err) { console.log('error:', err); res.sendStatus(500); diff --git a/package.json b/package.json old mode 100755 new mode 100644 diff --git a/sql.js b/sql.js deleted file mode 100755 index 7efdfe7..0000000 --- a/sql.js +++ /dev/null @@ -1,25 +0,0 @@ - -const CREATE_TABLE_IMAGES = "CREATE TABLE IF NOT EXISTS images (id INTEGER PRIMARY KEY, src TEXT, dataUri TEXT)"; -const CREATE_TABLE_QUESTIONS = "CREATE TABLE IF NOT EXISTS questions (id INTEGER PRIMARY KEY, updated DATETIME DEFAULT CURRENT_TIMESTAMP, text TEXT)"; -const CREATE_TABLE_ANSWERS = "CREATE TABLE IF NOT EXISTS answers (id INTEGER PRIMARY KEY, aid INTEGER, qid INTEGER, text TEXT, correct INTEGER, checked INTEGER)"; -const CREATE_TABLE_ANSWERING = "CREATE TABLE IF NOT EXISTS answering (id INTEGER PRIMARY KEY, created DATETIME DEFAULT CURRENT_TIMESTAMP, version TEXT, href TEXT)"; - -const SELECT_ALL = "SELECT q.id AS qid, q.text AS question, i.dataUri AS image, T2.id AS aid, T2.text AS answer, T2.correct FROM questions q \ -LEFT JOIN (SELECT qid, MAX(aid) AS maxid FROM answers GROUP BY qid) AS T1 ON q.id = T1.qid \ -LEFT JOIN answers AS T2 ON T2.aid = T1.maxid AND T2.qid = q.id \ -LEFT JOIN images AS i ON i.id = q.id ORDER BY T2.id DESC"; - - - -module.exports = { - SELECT_ALL: SELECT_ALL -} - - -app.get('/top-mistakes', function (req, res) { - db.all("SELECT q.id AS qid, q.text as question, a.acount AS mistakes FROM questions q " + - "JOIN (SELECT qid, count(*) as acount FROM answers WHERE correct != checked GROUP BY aid,qid) AS a ON a.qid = q.id ORDER BY mistakes DESC", - function (err, rows) { - res.render('index', { questions: rows }); - }); -}); diff --git a/tampermonkey2.js b/tampermonkey2.js new file mode 100644 index 0000000..6fa3f85 --- /dev/null +++ b/tampermonkey2.js @@ -0,0 +1,38 @@ +// ==UserScript== +// @name Walker +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match http://localhost:8080/* +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + var submit = document.querySelector('input[value=Kontrolli]'); + var reset = document.querySelector('input[value=Uuesti]'); + + function getRandomInt(min, max) { + return Math.floor(Math.random() * (max - min)) + min; + } + + if (submit) { + console.log('submit form'); + Array.prototype.slice.call(document.querySelectorAll('table.popup input[type="checkbox"]')).forEach(function(cb) { + var checked = !Math.floor(Math.random()*2); + cb.checked = checked; + console.log(cb.value, checked); + }); + setTimeout(function () { + submit.click() + }, getRandomInt(30000, 60000)); + } else if (reset) { + console.log('reset form'); + setTimeout(function () { + reset.click() + }, getRandomInt(10000, 30000)); + } + +})();