From aeaefedb6cb51761266c94034bea8e7b214e38ee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Jun 2024 09:58:11 +0200 Subject: [PATCH 1/5] chore(deps): lock file maintenance (#219) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 98de5d6..22d61f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -59,9 +59,9 @@ __metadata: linkType: hard "@eslint/object-schema@npm:^2.1.3": - version: 2.1.3 - resolution: "@eslint/object-schema@npm:2.1.3" - checksum: 10c0/ee892d0112ee7ec86312dfb1fa718da76b2d446e3495b9ec1f3ef31382a335d31420b76f3def175b96f7c3517c88fc860fec049d62a81d444237a23881559403 + version: 2.1.4 + resolution: "@eslint/object-schema@npm:2.1.4" + checksum: 10c0/e9885532ea70e483fb007bf1275968b05bb15ebaa506d98560c41a41220d33d342e19023d5f2939fed6eb59676c1bda5c847c284b4b55fce521d282004da4dda languageName: node linkType: hard @@ -147,11 +147,11 @@ __metadata: linkType: hard "acorn@npm:^8.11.3": - version: 8.11.3 - resolution: "acorn@npm:8.11.3" + version: 8.12.0 + resolution: "acorn@npm:8.12.0" bin: acorn: bin/acorn - checksum: 10c0/3ff155f8812e4a746fee8ecff1f227d527c4c45655bb1fad6347c3cb58e46190598217551b1500f18542d2bbe5c87120cb6927f5a074a59166fbdd9468f0a299 + checksum: 10c0/a19f9dead009d3b430fa3c253710b47778cdaace15b316de6de93a68c355507bc1072a9956372b6c990cbeeb167d4a929249d0faeb8ae4bb6911d68d53299549 languageName: node linkType: hard From 097546e413871584bd5f560ff764b059ab1baf16 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:03:38 +0200 Subject: [PATCH 2/5] chore(deps): update dependency globals to v15.5.0 (#220) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index e4d07c8..451b30d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "eslint": "9.4.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-userscripts": "0.5.3", - "globals": "15.4.0", + "globals": "15.5.0", "prettier": "3.3.2", "userscript-meta": "1.0.1" } diff --git a/yarn.lock b/yarn.lock index 22d61f5..37b3d66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -499,10 +499,10 @@ __metadata: languageName: node linkType: hard -"globals@npm:15.4.0": - version: 15.4.0 - resolution: "globals@npm:15.4.0" - checksum: 10c0/19041b8fd49deb154e1cb706c82756ab7184c8ae3495aab183efcad9edd1b6320cc54af1a9110d8699245bef124834b004a8156ca988ba7814c25ec71a43f6a4 +"globals@npm:15.5.0": + version: 15.5.0 + resolution: "globals@npm:15.5.0" + checksum: 10c0/f13c3cb0c6d49b9d23e447b86e33ca6139753087060c3063863c0dd2b5d79f4a114c48d20e321916e6c3701adb3f6b67d6ac8d8ed2bae6da45482c968532d4e2 languageName: node linkType: hard @@ -865,7 +865,7 @@ __metadata: eslint: "npm:9.4.0" eslint-config-prettier: "npm:9.1.0" eslint-plugin-userscripts: "npm:0.5.3" - globals: "npm:15.4.0" + globals: "npm:15.5.0" prettier: "npm:3.3.2" userscript-meta: "npm:1.0.1" languageName: unknown From a29c64206311b88e5dc842887d3b598f8e5ded2e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:04:15 +0200 Subject: [PATCH 3/5] chore(deps): update eslint to v9.5.0 (#221) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 4 ++-- yarn.lock | 40 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 451b30d..f1bd4ac 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ "prettier:write": "prettier --write --cache --cache-strategy content ." }, "devDependencies": { - "@eslint/js": "9.4.0", + "@eslint/js": "9.5.0", "@types/eslint": "8.56.10", "@types/tampermonkey": "5.0.3", "darkreader": "4.9.86", - "eslint": "9.4.0", + "eslint": "9.5.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-userscripts": "0.5.3", "globals": "15.5.0", diff --git a/yarn.lock b/yarn.lock index 37b3d66..79eec79 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23,14 +23,14 @@ __metadata: languageName: node linkType: hard -"@eslint/config-array@npm:^0.15.1": - version: 0.15.1 - resolution: "@eslint/config-array@npm:0.15.1" +"@eslint/config-array@npm:^0.16.0": + version: 0.16.0 + resolution: "@eslint/config-array@npm:0.16.0" dependencies: - "@eslint/object-schema": "npm:^2.1.3" + "@eslint/object-schema": "npm:^2.1.4" debug: "npm:^4.3.1" minimatch: "npm:^3.0.5" - checksum: 10c0/60947a188157f2f811cc2aedf3c2494fa10932178838f6a7c7e9a8bb106ab51b4b4e571f49ae63cdd3884002b78631e4395be25d4ae52470360fc7fb463303d2 + checksum: 10c0/b9d04409151dc95ec6b5e04e1e185a808d58e18cfc7340adc1e9420a5ff15843a0a308fb2cd9a2b354652885c2bebbcd5515814e93e9c9133f423891b6e53c70 languageName: node linkType: hard @@ -51,14 +51,14 @@ __metadata: languageName: node linkType: hard -"@eslint/js@npm:9.4.0": - version: 9.4.0 - resolution: "@eslint/js@npm:9.4.0" - checksum: 10c0/7ffc508d3e9cd496cab7f08c5ba8f97851c8adaea3ebff8804b1c3b4662aa7aac7e9c3b597f7e47fdc29319a107bcf892865070a6b113c2e4d19f8fa1f99f569 +"@eslint/js@npm:9.5.0": + version: 9.5.0 + resolution: "@eslint/js@npm:9.5.0" + checksum: 10c0/dacf51ec2d5b4c8d1315d21a0ff761235d9e39b2391cb945138c58dc512a6c18949c40b644235f5c4fdf5b637ef8f881214acc496dddf46b718529bf22af42ac languageName: node linkType: hard -"@eslint/object-schema@npm:^2.1.3": +"@eslint/object-schema@npm:^2.1.4": version: 2.1.4 resolution: "@eslint/object-schema@npm:2.1.4" checksum: 10c0/e9885532ea70e483fb007bf1275968b05bb15ebaa506d98560c41a41220d33d342e19023d5f2939fed6eb59676c1bda5c847c284b4b55fce521d282004da4dda @@ -337,15 +337,15 @@ __metadata: languageName: node linkType: hard -"eslint@npm:9.4.0": - version: 9.4.0 - resolution: "eslint@npm:9.4.0" +"eslint@npm:9.5.0": + version: 9.5.0 + resolution: "eslint@npm:9.5.0" dependencies: "@eslint-community/eslint-utils": "npm:^4.2.0" "@eslint-community/regexpp": "npm:^4.6.1" - "@eslint/config-array": "npm:^0.15.1" + "@eslint/config-array": "npm:^0.16.0" "@eslint/eslintrc": "npm:^3.1.0" - "@eslint/js": "npm:9.4.0" + "@eslint/js": "npm:9.5.0" "@humanwhocodes/module-importer": "npm:^1.0.1" "@humanwhocodes/retry": "npm:^0.3.0" "@nodelib/fs.walk": "npm:^1.2.8" @@ -357,7 +357,7 @@ __metadata: eslint-scope: "npm:^8.0.1" eslint-visitor-keys: "npm:^4.0.0" espree: "npm:^10.0.1" - esquery: "npm:^1.4.2" + esquery: "npm:^1.5.0" esutils: "npm:^2.0.2" fast-deep-equal: "npm:^3.1.3" file-entry-cache: "npm:^8.0.0" @@ -377,7 +377,7 @@ __metadata: text-table: "npm:^0.2.0" bin: eslint: bin/eslint.js - checksum: 10c0/826c901812536451e1bdb151359098db3a01ee9ff41775d5e97553626d07f7319cb2a0fd54176ef8e2e057105874077426b5d408ee6e8cff06bb814651f4c004 + checksum: 10c0/1c83d94ccfd6d97474aaaf463714eba7afa040639ad9191db430d34e9e2851ba14510651de69b52f26ee30611caf0fa4c66b3fb73bb71df6ab10cef5bb44bb32 languageName: node linkType: hard @@ -392,7 +392,7 @@ __metadata: languageName: node linkType: hard -"esquery@npm:^1.4.2": +"esquery@npm:^1.5.0": version: 1.5.0 resolution: "esquery@npm:1.5.0" dependencies: @@ -858,11 +858,11 @@ __metadata: version: 0.0.0-use.local resolution: "uzl-better-moodle@workspace:." dependencies: - "@eslint/js": "npm:9.4.0" + "@eslint/js": "npm:9.5.0" "@types/eslint": "npm:8.56.10" "@types/tampermonkey": "npm:5.0.3" darkreader: "npm:4.9.86" - eslint: "npm:9.4.0" + eslint: "npm:9.5.0" eslint-config-prettier: "npm:9.1.0" eslint-plugin-userscripts: "npm:0.5.3" globals: "npm:15.5.0" From 6aac35237c4033964f159d5553ac15ad99aae01f Mon Sep 17 00:00:00 2001 From: Yorik Hansen Date: Mon, 17 Jun 2024 10:04:59 +0200 Subject: [PATCH 4/5] feat(quickRoleChange): Make switching roles as easy as switching lang (#215) * feat(quickRoleChange): Make switching roles as easy as switching language * fix(quickRoleChange): Fix overflowing role names * refactor(quickRoleChange): Run eslint and prettier * refactor(quickRoleChange): Remove one level of indentation * fix(quickROleChange): Fix translations * fix(quickRoleChange): Don't show new-badge for this setting * style(quickRoleChange): Fix style after resolving merge conflicts --- redesign.user.js | 114 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/redesign.user.js b/redesign.user.js index d2b700a..d97508e 100644 --- a/redesign.user.js +++ b/redesign.user.js @@ -83,6 +83,11 @@ const TRANSLATIONS = { holiday: 'Feiertag', }, }, + quickRoleChange: { + defaultSwitchRole: 'Zur Moodle Rollenwechsel-Seite gehen', + goBack: 'Zurück zum Nutzermenü', + roleSelector: 'Rollen-Auswahl', + }, modals: { settings: { title: 'Einstellungen', @@ -316,6 +321,11 @@ Viele Grüße trans: 'Transgender', }, }, + quickRoleChange: { + name: 'Schneller Rollenwechsel', + description: + 'Ermöglicht es (mit den passenden Berechtigungen), die Betrachtung eines Kurses mit einer anderen Rolle direkt über das Profil-Dropdown zu ändern.', + }, }, darkmode: { _title: 'Darkmode', @@ -528,6 +538,11 @@ Viele Grüße holiday: 'Public Holiday', }, }, + quickRoleChange: { + defaultSwitchRole: 'Go to Moodle switch role page', + goBack: 'Go back to user menu', + roleSelector: 'Role selector', + }, modals: { settings: { title: 'Preferences', @@ -764,6 +779,11 @@ Best regards trans: 'Transgender', }, }, + quickRoleChange: { + name: 'Quick role change', + description: + 'Allows (with the appropriate permissions) to change the view of a course with a different role directly via the profile dropdown.', + }, }, darkmode: { _title: 'Darkmode', @@ -2595,6 +2615,7 @@ const SETTINGS = [ 'gay', 'trans', ]), + new BooleanSetting('general.quickRoleChange', true), 'darkmode', $t('settings.darkmode._description'), new SelectSetting('darkmode.mode', 'off', ['off', 'on', 'auto']).onInput( @@ -2712,6 +2733,7 @@ const existingSettings = new Set([ 'general.speiseplan', 'general.googlyEyes', 'general.semesterzeiten', + 'general.quickRoleChange', 'darkmode.mode', 'darkmode.brightness', 'darkmode.contrast', @@ -4472,6 +4494,98 @@ const updateDarkReaderMode = (live = false) => { updateDarkReaderMode(); // endregion +// region Feature: general.quickRoleChange +if (getSetting('general.quickRoleChange')) { + ready(() => { + const usermenu = document.getElementById('usermenu-carousel'); + const usermenuInner = usermenu?.querySelector('.carousel-inner'); + const roleSelectBtn = usermenu?.querySelector( + '.dropdown-item[href*="switchrole.php"]' + ); + if (!roleSelectBtn) return; + + const rolesUrl = roleSelectBtn.href; + fetch(rolesUrl) + .then(response => response.text()) + .then(html => { + const parser = new DOMParser(); + const doc = parser.parseFromString(html, 'text/html'); + return doc.querySelectorAll('form[action*="switchrole.php"]'); + }) + .then(forms => { + const roles = []; + forms.forEach(form => { + const role = { + id: form.querySelector('input[name="id"]').value, + switchrole: form.querySelector( + 'input[name="switchrole"]' + ).value, + returnurl: form.querySelector('input[name="returnurl"]') + .value, + sesskey: form.querySelector('input[name="sesskey"]') + .value, + title: form.querySelector('button').textContent, + }; + roles.push(role); + }); + return roles; + }) + .then(roles => { + if (roles.length === 0) return; + + const roleSelecotrItemId = PREFIX('role-selector-item'); + const roleSelectorItem = document.createElement('div'); + roleSelectorItem.id = roleSelecotrItemId; + roleSelectorItem.classList.add('carousel-item', 'submenu'); + roleSelectorItem.setAttribute('role', 'menu'); + roleSelectorItem.setAttribute( + 'aria-label', + $t('quickRoleChange.roleSelector') + ); + roleSelectorItem.setAttribute('tabindex', -1); + + roleSelectorItem.innerHTML = ` +
+
+ + ${$t('quickRoleChange.roleSelector')} +
+ + + + +
+ `; + + usermenuInner?.append(roleSelectorItem); + + roleSelectBtn.href = '#'; + roleSelectBtn.classList.add('carousel-navigation-link'); + roleSelectBtn.dataset.carouselTargetId = roleSelecotrItemId; + }); + }); +} +// endregion + // region Feature: Dashboard right sidebar // add a right sidebar with timeline and upcoming events on Dashboard if (isDashboard) { From 996134e3d300d54491201000074788ed40b9d14f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:16:55 +0200 Subject: [PATCH 5/5] chore(main): release 1.38.0 (#222) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 7 +++++++ package.json | 2 +- redesign.user.js | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cd451e1..2b02a05 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.37.1" + ".": "1.38.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 53831c4..73a480d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.38.0](https://github.com/jxn-30/better-moodle/compare/1.37.1...1.38.0) (2024-06-17) + + +### Features + +* **quickRoleChange:** Make switching roles as easy as switching lang ([#215](https://github.com/jxn-30/better-moodle/issues/215)) ([6aac352](https://github.com/jxn-30/better-moodle/commit/6aac35237c4033964f159d5553ac15ad99aae01f)) + ## [1.37.1](https://github.com/jxn-30/better-moodle/compare/1.37.0...1.37.1) (2024-06-13) diff --git a/package.json b/package.json index f1bd4ac..8a832ec 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "uzl-better-moodle", "description": "Improves the new weird Moodle 4 UI on UzL-Moodle", - "version": "1.37.1", + "version": "1.38.0", "packageManager": "yarn@4.3.0", "type": "module", "private": true, diff --git a/redesign.user.js b/redesign.user.js index d97508e..05b53e4 100644 --- a/redesign.user.js +++ b/redesign.user.js @@ -2,7 +2,7 @@ // @name 🎓️ UzL: better-moodle // @namespace https://uni-luebeck.de // @ x-release-please-start-version -// @version 1.37.1 +// @version 1.38.0 // @ x-release-please-end // @author Jan (jxn_30) // @description Improves UzL-Moodle by cool features and design improvements.