mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-27 20:03:45 +03:00
Add fully functional mods
This commit is contained in:
parent
df09b7e0ec
commit
7076724ac0
|
@ -8,6 +8,7 @@ import getTabPanel from './TabPanel';
|
|||
import getPacChooser from './PacChooser';
|
||||
import getNotifications from './Notifications';
|
||||
import getExceptions from './Exceptions';
|
||||
import getMods from './Mods';
|
||||
|
||||
import getFooter from './Footer';
|
||||
|
||||
|
@ -19,6 +20,7 @@ export default function getApp(theState) {
|
|||
const PacChooser = getPacChooser(theState);
|
||||
const Notifications = getNotifications(theState);
|
||||
const Exceptions = getExceptions(theState);
|
||||
const Mods = getMods(theState);
|
||||
|
||||
const Footer = getFooter(theState);
|
||||
|
||||
|
@ -152,7 +154,7 @@ export default function getApp(theState) {
|
|||
},
|
||||
{
|
||||
label: 'Модификаторы',
|
||||
content: "Modificators().render(this.props)",
|
||||
content: createElement(Mods, props),
|
||||
},
|
||||
{
|
||||
label: 'Уведомления',
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
import Inferno, { linkEvent } from 'inferno';
|
||||
|
||||
export default function getApplyMods(theState) {
|
||||
|
||||
const resetMods = function resetMods(props) {
|
||||
|
||||
const ifSure = props.bgWindow.confirm('Сбросиь все модификаторы и ИСКЛЮЧЕНИЯ?');
|
||||
if (!ifSure) {
|
||||
return false;
|
||||
}
|
||||
props.funs.conduct(
|
||||
'Сбрасываем...',
|
||||
(cb) => {
|
||||
|
||||
props.apis.pacKitchen.resetToDefaults();
|
||||
props.bgWindow.utils.fireRequest('ip-to-host-reset-to-defaults', cb);
|
||||
|
||||
},
|
||||
'Откройте окно заново для отображения эффекта.',
|
||||
() => window.close()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
return function ApplyMods(props) {
|
||||
|
||||
return (
|
||||
<section class="controlRow horFlex" style="margin-top: 1em">
|
||||
<input type="button" value="Применить" disabled={props.disabled} onClick={props.onClick}/>
|
||||
<a href="" onClick={linkEvent(props, resetMods)}>К изначальным!</a>
|
||||
</section>
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
};
|
|
@ -243,7 +243,6 @@ export default function getExcEditor(theState) {
|
|||
if (ifBackspacedOneChar) {
|
||||
removeEditedHost();
|
||||
}
|
||||
//
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ export default function getInfoRow() {
|
|||
disabled={props.disabled}
|
||||
/>
|
||||
<div class={scopedCss.labelContainer}>
|
||||
<label for={iddy}>{props.conf.label}</label>
|
||||
<label for={iddy} dangerouslySetInnerHTML={{__html: props.conf.label}}></label>
|
||||
{props.children}
|
||||
</div>
|
||||
{props.conf.desc
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
import Inferno from 'inferno';
|
||||
import Component from 'inferno-component';
|
||||
import createElement from 'inferno-create-element';
|
||||
import css from 'csjs-inject';
|
||||
|
||||
import getInfoLi from './InfoLi';
|
||||
import getApplyMods from './ApplyMods';
|
||||
|
||||
export default function getMods(theState) {
|
||||
|
||||
const InfoLi = getInfoLi(theState);
|
||||
const ApplyMods = getApplyMods(theState);
|
||||
|
||||
return class Mods extends Component {
|
||||
|
||||
getOrderedConfigs() {
|
||||
|
||||
return this.props.apis.pacKitchen.getOrderedConfigs('general');
|
||||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
|
||||
super(props);
|
||||
this.state = {
|
||||
orderedConfigs: this.getOrderedConfigs(),
|
||||
ifChangesStashed: false,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
render(props) {
|
||||
|
||||
return (
|
||||
<section>
|
||||
<ul onChange={() => { this.setState({ifChangesStashed: true}); }}>
|
||||
{
|
||||
this.state.orderedConfigs.map((conf, index) =>
|
||||
<InfoLi conf={conf} type='checkbox' checked={conf.value} key={index} onClick={() => {
|
||||
|
||||
const newConfigs = this.state.orderedConfigs.map((c) => Object.assign({}, c)); // Shallow.
|
||||
newConfigs[index].value = !newConfigs[index].value;
|
||||
this.setState({orderedConfigs: newConfigs});
|
||||
|
||||
}}/>
|
||||
)
|
||||
}
|
||||
</ul>
|
||||
{createElement(ApplyMods, Object.assign({}, props,
|
||||
{
|
||||
disabled: !this.state.ifChangesStashed,
|
||||
onClick: () => {
|
||||
|
||||
const oldMods = this.props.apis.pacKitchen.getPacMods();
|
||||
const newMods = this.state.orderedConfigs.reduce((acc, conf) => {
|
||||
|
||||
acc[conf.key] = conf.value;
|
||||
return acc;
|
||||
|
||||
}, oldMods);
|
||||
|
||||
this.props.funs.conduct(
|
||||
'Применяем настройки...',
|
||||
(cb) => this.props.apis.pacKitchen.keepCookedNowAsync(newMods, cb),
|
||||
'Настройки применены.',
|
||||
() => this.setState({ifChangesStashed: false})
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
};
|
|
@ -5,22 +5,23 @@ import createElement from 'inferno-create-element';
|
|||
import appendGlobalCss from './globalCss';
|
||||
import getApp from './components/App';
|
||||
|
||||
chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
||||
backgroundPage.apis.errorHandlers.installListenersOn(
|
||||
chrome.runtime.getBackgroundPage( (bgWindow) =>
|
||||
bgWindow.apis.errorHandlers.installListenersOn(
|
||||
window, 'PUP', async() => {
|
||||
|
||||
let theState;
|
||||
{
|
||||
const apis = backgroundPage.apis;
|
||||
const apis = bgWindow.apis;
|
||||
|
||||
theState = {
|
||||
utils: backgroundPage.utils,
|
||||
apis: backgroundPage.apis,
|
||||
utils: bgWindow.utils,
|
||||
apis: bgWindow.apis,
|
||||
flags: {
|
||||
/* Shortcuts to boolean values. */
|
||||
ifNotControlled: !apis.errorHandlers.ifControllable,
|
||||
ifMini: apis.version.ifMini,
|
||||
},
|
||||
bgWindow,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user