Merge branch 'rianadon-theme-by-url'

This commit is contained in:
n1474335 2019-10-27 15:17:33 +00:00
commit 89d979d92e
3 changed files with 28 additions and 2 deletions

View File

@ -71,6 +71,12 @@ You can use as many operations as you like in simple or complex ways. Some examp
- It should be noted that none of your recipe configuration or input (either text or files) is ever sent to the CyberChef web server - all processing is carried out within your browser, on your own computer.
- Due to this feature, CyberChef can be downloaded and run locally. You can use the link in the top left corner of the app to download a full copy of CyberChef and drop it into a virtual machine, share it with other people, or host it in a closed network.
## Url prefilling
By manipulation of CyberChef's url hash, you can change the initial settings with which the page opens.
The format is `https://gchq.github.io/CyberChef/#recipe=Function()&input=...`
Supported options are `recipe`, `input`, and `theme`.
## Browser support

View File

@ -453,6 +453,7 @@ class App {
* Searches the URI parameters for recipe and input parameters.
* If recipe is present, replaces the current recipe with the recipe provided in the URI.
* If input is present, decodes and sets the input to the one provided in the URI.
* If theme is present, uses the theme.
*
* @fires Manager#statechange
*/
@ -491,6 +492,11 @@ class App {
} catch (err) {}
}
// Read in theme from URI params
if (this.uriParams.theme) {
this.manager.options.changeTheme(Utils.escapeHtml(this.uriParams.theme));
}
this.autoBakePause = false;
window.dispatchEvent(this.manager.statechange);
}

View File

@ -153,14 +153,28 @@ class OptionsWaiter {
/**
* Changes the theme by setting the class of the <html> element.
* Theme change event listener
*
* @param {Event} e
*/
themeChange(e) {
const themeClass = e.target.value;
document.querySelector(":root").className = themeClass;
this.changeTheme(themeClass);
}
/**
* Changes the theme by setting the class of the <html> element.
*
* @param (string} theme
*/
changeTheme(theme) {
document.querySelector(":root").className = theme;
// Update theme selection
const themeSelect = document.getElementById("theme");
themeSelect.selectedIndex = themeSelect.querySelector(`option[value="${theme}"`).index;
}