diff --git a/js/background.js b/js/background.js index 0856f0b..4183c14 100644 --- a/js/background.js +++ b/js/background.js @@ -1,9 +1,13 @@ -chrome.storage.sync.get(['show_answers','true_answers'], function(items) { +chrome.storage.sync.get(['show_answers','simple_mode','true_answers'], function(items) { var choise=items['show_answers']; if(choise == undefined) choise = true; if(choise) chrome.browserAction.setBadgeText({text: "on"}); else chrome.browserAction.setBadgeText({text: "off"}); + choise=items['simple_mode']; + if(choise == undefined) choise = false; + if(choise) chrome.browserAction.setBadgeText({text: "on"}); + choise=items['true_answers']; if(choise == undefined) choise = false; if(choise) chrome.browserAction.setBadgeText({text: "on"}); diff --git a/js/show_answers.js b/js/show_answers.js index 1983c1d..6adecf0 100644 --- a/js/show_answers.js +++ b/js/show_answers.js @@ -22,9 +22,11 @@ $(document).ready(function() { }); } }) + //Показать ответы function show() { - $('*[class^="correct"]').show().removeClass("ng-hide").parent().show().removeClass("ng-hide"); - $("table.ng-hide").removeClass("ng-hide"); - $("section").css("user-select","initial"); + $('*[class^="correct"]').show().removeClass('ng-hide').parent().show().removeClass('ng-hide'); + $('*[ng-show^="doShowAnswer"]').removeClass('ng-hide'); + $('table.ng-hide').removeClass('ng-hide'); + $('section').css('user-select','initial'); } \ No newline at end of file diff --git a/js/simple_mode.js b/js/simple_mode.js new file mode 100644 index 0000000..11eb33f --- /dev/null +++ b/js/simple_mode.js @@ -0,0 +1,62 @@ +chrome.storage.sync.get(['simple_mode'], function(items) { + var choise=items['simple_mode']; + if(choise == undefined) choise = false; + if(choise) simple_mode_on(); +}); +//id и class ненужных элементов +var massiv_id = ['header','dashboard-toogle','skip-link','tools-iframe','cboxOverlay','colorbox','autologout-cache-check']; +var massiv_name = ['content-page-header','header-content scorm-header clearfix','region region-footer','left-nav hide','ipad-popup','top-btn save ipad-pos f-right disableMultipleClick-processed']; +//Включить простого вида +function simple_mode_on() { + var a; + a = document.getElementsByClassName('header-content scorm-header clearfix addBorder-top')[0]; + if(a) a.setAttribute("class", "header-content scorm-header clearfix"); + a = document.getElementsByClassName('main-content remove-pad hide clearfix')[0]; + if(a) a.setAttribute("style", "display:block;"); + a = document.getElementsByClassName('header-content scorm-header clearfix addBorder-top')[0]; + if(a) a.setAttribute("class", "header-content scorm-header clearfix"); + a = document.getElementById('content'); + if(a) a.setAttribute('id','content_'); + a = document.getElementsByClassName("scromoverlaydiv")[0]; + if(a) a.remove(); + a = document.getElementById('content-iframe'); + if(a) a.setAttribute("style", "position:relative;display:block;height:93vh;visibility: visible;margin-left:-0.7%") + //Убираем отображение всех элементов из массивов + massiv_id.forEach(function(item, i, arr) { + a = document.getElementById(item); + if(a) a.setAttribute("style","transform: scale(0);margin-top:-9%"); + }); + massiv_name.forEach(function(item, i, arr) { + a = document.getElementsByClassName(item)[0]; + if(a) a.setAttribute("style","transform: scale(0);"); + }); +} +//Выключить простого вида +function simple_mode_off() { + var a; + a = document.getElementsByClassName('dashboard-toggle-bg')[0]; + if(a) a.innerHTML = "Hide Dashboard"; + a = document.getElementById('content_'); + if(a) a.setAttribute('id','content'); + if(a) a.removeAttribute("style"); + a = document.getElementById('content-iframe'); + if(a) a.setAttribute("style", "position:relative;display:block;height:93vh;visibility: visible;"); + //Возвращаем отображение всех элементов из массивов + massiv_id.forEach(function(item, i, arr) { + a = document.getElementById(item); + if(a) a.removeAttribute("style"); + }); + massiv_name.forEach(function(item, i, arr) { + a = document.getElementsByClassName(item)[0]; + if(a) a.removeAttribute("style"); + }); +} +//Ожидание команд +chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { + if(request.command==="simple_mode_on") { + simple_mode_on(); + } + if(request.command==="simple_mode_off") { + simple_mode_off(); + } +}); \ No newline at end of file diff --git a/js/true_answers.js b/js/true_answers.js index 41a3888..585920c 100644 --- a/js/true_answers.js +++ b/js/true_answers.js @@ -23,7 +23,7 @@ function off() { chrome.webRequest.onBeforeRequest.removeListener(f); } } -//Прием сообщений +//Ожидание команд chrome.extension.onMessage.addListener(function(request, sender, sendResponse) { if(request.msg==="auto_on") { on(); diff --git a/manifest.json b/manifest.json index a27d135..5505e43 100644 --- a/manifest.json +++ b/manifest.json @@ -18,6 +18,10 @@ }, "content_scripts": [ { + "matches": [ "*://www.cambridgelms.org/*" ], + "js": [ "js/simple_mode.js" ], + "run_at": "document_end" + },{ "matches": [ "*://www.cambridgelms.org/*" ], "js": [ "js/jquery.js", "js/show_answers.js" ], "run_at": "document_idle", diff --git a/popup/popup.html b/popup/popup.html index 3bd5848..e867d4b 100644 --- a/popup/popup.html +++ b/popup/popup.html @@ -15,6 +15,13 @@
+ + +