Version 1.1.3
Убрал мерцание текста в меню расширения Добавил заготовку для автоматического заполнения тестов(На стадии тестирования, работает только часть заданий)
This commit is contained in:
parent
e9f4ad855c
commit
bb63305744
47
js/auto_mode.js
Normal file
47
js/auto_mode.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
//По окончании загрузки документа вызывается функция
|
||||||
|
$(document).ready(function() {
|
||||||
|
var path = window.location.pathname;
|
||||||
|
var page = path.split("/").pop();
|
||||||
|
if(page === 'index.html') {
|
||||||
|
//При получении команды 'auto_mode' заполняет ответы
|
||||||
|
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
||||||
|
if(request.command==="auto_mode") {
|
||||||
|
auto_mode();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//Если выбрана функция автоматического показа ответов запускается функция заполнения ответов
|
||||||
|
chrome.storage.sync.get(['auto_mode'], function(items) {
|
||||||
|
var choise=items['auto_mode'];
|
||||||
|
if(choise == undefined) choise = true;
|
||||||
|
if(choise){
|
||||||
|
var timerId = setInterval(auto_mode, 2000);
|
||||||
|
setTimeout(function() {
|
||||||
|
clearInterval(timerId);
|
||||||
|
}, 7000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//Заполнить ответы
|
||||||
|
function auto_mode() {
|
||||||
|
var test,answers;
|
||||||
|
|
||||||
|
test = document.getElementsByClassName('selectBox');
|
||||||
|
answers = document.getElementsByTagName('b');
|
||||||
|
if(test&&answers) fill_selectbox(test,answers);
|
||||||
|
}
|
||||||
|
//Заполнить задания, где есть selectBox
|
||||||
|
function fill_selectbox(test,answers) {
|
||||||
|
var test_arr = Array.prototype.slice.call(test);
|
||||||
|
var answers_arr = Array.prototype.slice.call(answers);
|
||||||
|
if(answers_arr)answers_arr.forEach(function(item, i) {
|
||||||
|
var a = item.innerHTML;
|
||||||
|
Array.prototype.slice.call(test_arr[i].options).forEach(function(item) {
|
||||||
|
// alert(item.value);
|
||||||
|
if(item.value.includes(a)) {
|
||||||
|
var b = item.value.replace(a, '');
|
||||||
|
if( b.search(/[a-zA-Z]/) === -1 ) test_arr[i].value = item.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
chrome.storage.sync.get(['show_answers','simple_mode','true_answers'], function(items) {
|
chrome.storage.sync.get(['show_mode','simple_mode','true_mode'], function(items) {
|
||||||
var choise=items['show_answers'];
|
var choise=items['show_mode'];
|
||||||
if(choise == undefined) choise = true;
|
if(choise == undefined) choise = true;
|
||||||
if(choise) chrome.browserAction.setBadgeText({text: "on"});
|
if(choise) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
else chrome.browserAction.setBadgeText({text: "off"});
|
else chrome.browserAction.setBadgeText({text: "off"});
|
||||||
@ -8,7 +8,7 @@ chrome.storage.sync.get(['show_answers','simple_mode','true_answers'], function(
|
|||||||
if(choise == undefined) choise = false;
|
if(choise == undefined) choise = false;
|
||||||
if(choise) chrome.browserAction.setBadgeText({text: "on"});
|
if(choise) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
|
|
||||||
choise=items['true_answers'];
|
choise=items['true_mode'];
|
||||||
if(choise == undefined) choise = false;
|
if(choise == undefined) choise = false;
|
||||||
if(choise) chrome.browserAction.setBadgeText({text: "on"});
|
if(choise) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
});
|
});
|
||||||
|
@ -10,8 +10,8 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//Если выбрана функция автоматического показа ответов заппускается функция показа ответов
|
//Если выбрана функция автоматического показа ответов заппускается функция показа ответов
|
||||||
chrome.storage.sync.get(['show_answers'], function(items) {
|
chrome.storage.sync.get(['show_mode'], function(items) {
|
||||||
var choise=items['show_answers'];
|
var choise=items['show_mode'];
|
||||||
if(choise == undefined) choise = true;
|
if(choise == undefined) choise = true;
|
||||||
if(choise){
|
if(choise){
|
||||||
var timerId = setInterval(show, 2000);
|
var timerId = setInterval(show, 2000);
|
@ -1,5 +1,5 @@
|
|||||||
chrome.storage.sync.get(['true_answers'], function(items) {
|
chrome.storage.sync.get(['true_mode'], function(items) {
|
||||||
var choise=items['true_answers'];
|
var choise=items['true_mode'];
|
||||||
if(choise == undefined) choise = false;
|
if(choise == undefined) choise = false;
|
||||||
if(choise) on();
|
if(choise) on();
|
||||||
});
|
});
|
@ -14,7 +14,7 @@
|
|||||||
"default_popup": "popup/popup.html"
|
"default_popup": "popup/popup.html"
|
||||||
},
|
},
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["js/background.js", "js/true_answers.js" ]
|
"scripts": ["js/background.js", "js/true_mode.js" ]
|
||||||
},
|
},
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
@ -23,7 +23,7 @@
|
|||||||
"run_at": "document_end"
|
"run_at": "document_end"
|
||||||
},{
|
},{
|
||||||
"matches": [ "*://www.cambridgelms.org/*" ],
|
"matches": [ "*://www.cambridgelms.org/*" ],
|
||||||
"js": [ "js/jquery.js", "js/show_answers.js" ],
|
"js": [ "js/jquery.js", "js/show_mode.js", "js/auto_mode.js" ],
|
||||||
"run_at": "document_idle",
|
"run_at": "document_idle",
|
||||||
"all_frames": true
|
"all_frames": true
|
||||||
}
|
}
|
||||||
|
@ -10,24 +10,29 @@
|
|||||||
<div class="shadow title_text">
|
<div class="shadow title_text">
|
||||||
<h1>LMS Answers</h1>
|
<h1>LMS Answers</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="button-add style style_4">
|
||||||
|
<input id="show_mode" type="checkbox">
|
||||||
|
<label for="show_mode" data-text="Показывать ответы"></label>
|
||||||
|
<div class="button-add__icon"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="button-add style style_1">
|
<div class="button-add style style_1">
|
||||||
<input id="show_answers" type="checkbox">
|
<input id="auto_mode" type="checkbox">
|
||||||
<label for="show_answers" data-on-text="Автоматический режим" data-off-text="Автоматический режим"></label>
|
<label for="auto_mode" data-text="Автоматический режим"></label>
|
||||||
|
<div class="button-add__icon"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="button-add style style_3">
|
||||||
|
<input id="true_mode" type="checkbox">
|
||||||
|
<label for="true_mode" data-text="Максимальные баллы"></label>
|
||||||
<div class="button-add__icon"></div>
|
<div class="button-add__icon"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="button-add style style_2">
|
<div class="button-add style style_2">
|
||||||
<input id="simple_mode" type="checkbox">
|
<input id="simple_mode" type="checkbox">
|
||||||
<label for="simple_mode" data-on-text="Упрощенная страница" data-off-text="Упрощенная страница"></label>
|
<label for="simple_mode" data-text="Упрощенная страница"></label>
|
||||||
<div class="button-add__icon"></div>
|
<div class="button-add__icon"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="button-add style style_3">
|
|
||||||
<input id="true_answers" type="checkbox">
|
|
||||||
<label for="true_answers" data-on-text="Максимальные баллы" data-off-text="Максимальные баллы"></label>
|
|
||||||
<div class="button-add__icon"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<button id="showBtn">Показать ответы</button>
|
<button id="showBtn">Показать ответы</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
showButton.addEventListener('click', function() {
|
showButton.addEventListener('click', function() {
|
||||||
show();
|
show();
|
||||||
}, false);
|
}, false);
|
||||||
var showChecker = document.getElementById('show_answers');
|
var autoChecker = document.getElementById('auto_mode');
|
||||||
|
autoChecker.addEventListener('change', function() {
|
||||||
|
saveOptions();
|
||||||
|
auto_mode();
|
||||||
|
}, false);
|
||||||
|
var showChecker = document.getElementById('show_mode');
|
||||||
showChecker.addEventListener('change', function() {
|
showChecker.addEventListener('change', function() {
|
||||||
saveOptions();
|
saveOptions();
|
||||||
if(showChecker.checked)show();
|
if(showChecker.checked)show();
|
||||||
@ -14,18 +19,18 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
saveOptions();
|
saveOptions();
|
||||||
simple_mode();
|
simple_mode();
|
||||||
}, false);
|
}, false);
|
||||||
var trueChecker = document.getElementById('true_answers');
|
var trueChecker = document.getElementById('true_mode');
|
||||||
trueChecker.addEventListener('change', function() {
|
trueChecker.addEventListener('change', function() {
|
||||||
saveOptions();
|
saveOptions();
|
||||||
autotrue();
|
true_mode();
|
||||||
}, false);
|
}, false);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
function loadOptions() {
|
function loadOptions() {
|
||||||
chrome.storage.sync.get(['show_answers','simple_mode','true_answers'], function(items) {
|
chrome.storage.sync.get(['show_mode','simple_mode','true_mode','auto_mode'], function(items) {
|
||||||
var choise=items['show_answers'];
|
var choise=items['show_mode'];
|
||||||
if(choise == undefined) choise = true;
|
if(choise == undefined) choise = true;
|
||||||
var select = document.getElementById("show_answers");
|
var select = document.getElementById("show_mode");
|
||||||
select.checked = choise;
|
select.checked = choise;
|
||||||
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
else chrome.browserAction.setBadgeText({text: "off"});
|
else chrome.browserAction.setBadgeText({text: "off"});
|
||||||
@ -36,17 +41,23 @@ function loadOptions() {
|
|||||||
select.checked = choise;
|
select.checked = choise;
|
||||||
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
|
|
||||||
choise=items['true_answers'];
|
choise=items['true_mode'];
|
||||||
if(choise == undefined) choise = false;
|
if(choise == undefined) choise = false;
|
||||||
var select = document.getElementById("true_answers");
|
var select = document.getElementById("true_mode");
|
||||||
|
select.checked = choise;
|
||||||
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
|
|
||||||
|
choise=items['auto_mode'];
|
||||||
|
if(choise == undefined) choise = false;
|
||||||
|
var select = document.getElementById("auto_mode");
|
||||||
select.checked = choise;
|
select.checked = choise;
|
||||||
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveOptions() {
|
function saveOptions() {
|
||||||
var select = document.getElementById("show_answers");
|
var select = document.getElementById("show_mode");
|
||||||
chrome.storage.sync.set({'show_answers': select.checked});
|
chrome.storage.sync.set({'show_mode': select.checked});
|
||||||
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
else chrome.browserAction.setBadgeText({text: "off"});
|
else chrome.browserAction.setBadgeText({text: "off"});
|
||||||
|
|
||||||
@ -54,8 +65,12 @@ function saveOptions() {
|
|||||||
chrome.storage.sync.set({'simple_mode': select.checked});
|
chrome.storage.sync.set({'simple_mode': select.checked});
|
||||||
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
|
|
||||||
select = document.getElementById("true_answers");
|
select = document.getElementById("true_mode");
|
||||||
chrome.storage.sync.set({'true_answers': select.checked});
|
chrome.storage.sync.set({'true_mode': select.checked});
|
||||||
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
|
|
||||||
|
select = document.getElementById("auto_mode");
|
||||||
|
chrome.storage.sync.set({'auto_mode': select.checked});
|
||||||
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
if(select.checked) chrome.browserAction.setBadgeText({text: "on"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +81,13 @@ function show() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function auto_mode() {
|
||||||
|
var query = { active: true, currentWindow: true };
|
||||||
|
chrome.tabs.query(query, function(tabs) {
|
||||||
|
chrome.tabs.sendMessage(tabs[0].id, {command: "auto_mode"});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function simple_mode() {
|
function simple_mode() {
|
||||||
var select = document.getElementById("simple_mode");
|
var select = document.getElementById("simple_mode");
|
||||||
var query = { active: true, currentWindow: true };
|
var query = { active: true, currentWindow: true };
|
||||||
@ -77,9 +99,9 @@ function simple_mode() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function autotrue() {
|
function true_mode() {
|
||||||
alert("Чтобы обновления вступили в силу обновите страницу");
|
alert("Чтобы обновления вступили в силу обновите страницу");
|
||||||
var select = document.getElementById("true_answers");
|
var select = document.getElementById("true_mode");
|
||||||
if(select.checked===true)
|
if(select.checked===true)
|
||||||
chrome.runtime.sendMessage({msg: "auto_on"})
|
chrome.runtime.sendMessage({msg: "auto_on"})
|
||||||
else
|
else
|
||||||
|
@ -55,16 +55,13 @@ body {
|
|||||||
transition: 0.2s ease-out; }
|
transition: 0.2s ease-out; }
|
||||||
|
|
||||||
.style label {
|
.style label {
|
||||||
|
will-change: transform;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
border-radius: 2rem; }
|
border-radius: 2rem; }
|
||||||
.style label:before {
|
|
||||||
content: attr(data-on-text); }
|
|
||||||
.style label:after {
|
|
||||||
content: attr(data-off-text); }
|
|
||||||
|
|
||||||
.style input[type=checkbox] + label {
|
.style input[type=checkbox] ~ label {
|
||||||
width: 210px;
|
width: 210px;
|
||||||
background: #FF5335; }
|
background: #FF5335; }
|
||||||
|
|
||||||
@ -79,40 +76,43 @@ body {
|
|||||||
.style input[type=checkbox]:checked ~ .button-add__icon:after {
|
.style input[type=checkbox]:checked ~ .button-add__icon:after {
|
||||||
transform: translate(30%) rotate(-45deg); }
|
transform: translate(30%) rotate(-45deg); }
|
||||||
|
|
||||||
.style .button-add__icon {
|
.button-add__icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
width: 30px; }
|
width: 30px; }
|
||||||
.style .button-add__icon:before, .style .button-add__icon:after {
|
.button-add__icon:before, .button-add__icon:after {
|
||||||
height: 3px;
|
height: 3px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1); }
|
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1); }
|
||||||
.style .button-add__icon:before {
|
.button-add__icon:before {
|
||||||
width: 17px;
|
width: 17px;
|
||||||
transform: rotate(90deg); }
|
transform: rotate(90deg); }
|
||||||
.style .button-add__icon:after {
|
.button-add__icon:after {
|
||||||
width: 17px;
|
width: 17px;
|
||||||
transform: rotate(0); }
|
transform: rotate(0); }
|
||||||
|
|
||||||
.style_1 label:before, .style_1 label:after {
|
.style_1 label:before, .style_1 label:after {
|
||||||
|
content: attr(data-text);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0.9rem;
|
right: 0.9rem; }
|
||||||
transition: all 0.2s .15s ease-out; }
|
|
||||||
.style_2 label:before, .style_2 label:after {
|
.style_2 label:before, .style_2 label:after {
|
||||||
|
content: attr(data-text);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 1.3rem;
|
right: 1.3rem; }
|
||||||
transition: all 0.2s .15s ease-out; }
|
|
||||||
.style_3 label:before, .style_3 label:after {
|
.style_3 label:before, .style_3 label:after {
|
||||||
|
content: attr(data-text);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 1.4rem;
|
right: 1.4rem; }
|
||||||
transition: all 0.2s .15s ease-out; }
|
.style_4 label:before, .style_4 label:after {
|
||||||
|
content: attr(data-text);
|
||||||
|
position: absolute;
|
||||||
|
right: 1.9rem; }
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
will-change: transform;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
Reference in New Issue
Block a user