mirror of
				https://gitlab.com/MrFry/moodle-test-userscript
				synced 2025-04-01 20:22:48 +02:00 
			
		
		
		
	small code refactoring
This commit is contained in:
		
							
								
								
									
										27
									
								
								main.js
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								main.js
									
									
									
									
									
								
							| @@ -511,7 +511,7 @@ class ResultsPageModell { | |||||||
|     var items = results[i].getElementsByTagName('label') |     var items = results[i].getElementsByTagName('label') | ||||||
|     var r = [] |     var r = [] | ||||||
|     for (var j = 0; j < items.length; j++) { |     for (var j = 0; j < items.length; j++) { | ||||||
|       function TryGetCorrect (j) { |       const TryGetCorrect = (j) => { | ||||||
|         var cn = items[j].parentNode.className |         var cn = items[j].parentNode.className | ||||||
|         if (cn.includes('correct')) { return cn.includes('correct') && !cn.includes('incorrect') } |         if (cn.includes('correct')) { return cn.includes('correct') && !cn.includes('incorrect') } | ||||||
|       } |       } | ||||||
| @@ -698,14 +698,14 @@ var MPM = new MiscPageModell() | |||||||
| // : }}} | // : }}} | ||||||
|  |  | ||||||
| // : Main function {{{ | // : Main function {{{ | ||||||
| function Main () { | function Main () { // eslint-disable-line | ||||||
|   'use strict' |   'use strict' | ||||||
|   console.time('main') |   console.time('main') | ||||||
|  |  | ||||||
|   Init(function (count, subjCount) { |   Init(function (count, subjCount) { | ||||||
|     var url = location.href |     var url = location.href // eslint-disable-line | ||||||
|  |  | ||||||
|     let skipLoad = GM_getValue('skipLoad') |     let skipLoad = GM_getValue('skipLoad') // eslint-disable-line | ||||||
|     if (count === -2 && subjCount === -2 && skipLoad) { |     if (count === -2 && subjCount === -2 && skipLoad) { | ||||||
|       if (url.includes('/quiz/') && url.includes('attempt.php')) { |       if (url.includes('/quiz/') && url.includes('attempt.php')) { | ||||||
|         ShowMessage({ |         ShowMessage({ | ||||||
| @@ -728,7 +728,7 @@ function Main () { | |||||||
|           m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!', |           m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!', | ||||||
|           isSimple: true |           isSimple: true | ||||||
|         }, undefined, function () { |         }, undefined, function () { | ||||||
|           GM_openInTab(serverAdress + 'lred', { |           GM_openInTab(serverAdress + 'lred', { // eslint-disable-line | ||||||
|             active: true |             active: true | ||||||
|           }) |           }) | ||||||
|         }) |         }) | ||||||
| @@ -755,12 +755,12 @@ function Main () { | |||||||
| // : Loading {{{ | // : Loading {{{ | ||||||
|  |  | ||||||
| function Init (cwith) { | function Init (cwith) { | ||||||
|   if (false) { |   if (false) { // eslint-disable-line | ||||||
|     GM_setValue('version16', undefined) |     GM_setValue('version16', undefined) // eslint-disable-line | ||||||
|     GM_setValue('version15', undefined) |     GM_setValue('version15', undefined) // eslint-disable-line | ||||||
|     GM_setValue('firstRun', undefined) // GM_getValue("lastVerson") == undefined => firstrun |     GM_setValue('firstRun', undefined) // eslint-disable-line | ||||||
|     GM_setValue('showQuestions', undefined) |     GM_setValue('showQuestions', undefined) // eslint-disable-line | ||||||
|     GM_setValue('showSplash', undefined) |     GM_setValue('showSplash', undefined) // eslint-disable-line | ||||||
|   } |   } | ||||||
|   var url = location.href // window location |   var url = location.href // window location | ||||||
|   var count = -1 // loaded question count. stays -1 if the load failed. |   var count = -1 // loaded question count. stays -1 if the load failed. | ||||||
| @@ -831,10 +831,9 @@ function Version15 () { | |||||||
|  |  | ||||||
| function Version16 () { | function Version16 () { | ||||||
|   var version16 = GM_getValue('version16') // if the current run is the frst |   var version16 = GM_getValue('version16') // if the current run is the frst | ||||||
|   if (version16 == undefined || version16 == true) // if its undefined, or true |   if (version16 === undefined || version16 === true) { | ||||||
|   { |  | ||||||
|     var i = 0 |     var i = 0 | ||||||
|     while (GM_getValue('Is' + i + 'Active') != undefined) { |     while (GM_getValue('Is' + i + 'Active') !== undefined) { | ||||||
|       GM_setValue('Is' + i + 'Active', false) |       GM_setValue('Is' + i + 'Active', false) | ||||||
|       i++ |       i++ | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user