mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2025-07-10 08:12:21 +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 getPacChooser from './PacChooser';
|
||||||
import getNotifications from './Notifications';
|
import getNotifications from './Notifications';
|
||||||
import getExceptions from './Exceptions';
|
import getExceptions from './Exceptions';
|
||||||
|
import getMods from './Mods';
|
||||||
|
|
||||||
import getFooter from './Footer';
|
import getFooter from './Footer';
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ export default function getApp(theState) {
|
||||||
const PacChooser = getPacChooser(theState);
|
const PacChooser = getPacChooser(theState);
|
||||||
const Notifications = getNotifications(theState);
|
const Notifications = getNotifications(theState);
|
||||||
const Exceptions = getExceptions(theState);
|
const Exceptions = getExceptions(theState);
|
||||||
|
const Mods = getMods(theState);
|
||||||
|
|
||||||
const Footer = getFooter(theState);
|
const Footer = getFooter(theState);
|
||||||
|
|
||||||
|
@ -152,7 +154,7 @@ export default function getApp(theState) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Модификаторы',
|
label: 'Модификаторы',
|
||||||
content: "Modificators().render(this.props)",
|
content: createElement(Mods, props),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Уведомления',
|
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) {
|
if (ifBackspacedOneChar) {
|
||||||
removeEditedHost();
|
removeEditedHost();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ export default function getInfoRow() {
|
||||||
disabled={props.disabled}
|
disabled={props.disabled}
|
||||||
/>
|
/>
|
||||||
<div class={scopedCss.labelContainer}>
|
<div class={scopedCss.labelContainer}>
|
||||||
<label for={iddy}>{props.conf.label}</label>
|
<label for={iddy} dangerouslySetInnerHTML={{__html: props.conf.label}}></label>
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
{props.conf.desc
|
{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 appendGlobalCss from './globalCss';
|
||||||
import getApp from './components/App';
|
import getApp from './components/App';
|
||||||
|
|
||||||
chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
chrome.runtime.getBackgroundPage( (bgWindow) =>
|
||||||
backgroundPage.apis.errorHandlers.installListenersOn(
|
bgWindow.apis.errorHandlers.installListenersOn(
|
||||||
window, 'PUP', async() => {
|
window, 'PUP', async() => {
|
||||||
|
|
||||||
let theState;
|
let theState;
|
||||||
{
|
{
|
||||||
const apis = backgroundPage.apis;
|
const apis = bgWindow.apis;
|
||||||
|
|
||||||
theState = {
|
theState = {
|
||||||
utils: backgroundPage.utils,
|
utils: bgWindow.utils,
|
||||||
apis: backgroundPage.apis,
|
apis: bgWindow.apis,
|
||||||
flags: {
|
flags: {
|
||||||
/* Shortcuts to boolean values. */
|
/* Shortcuts to boolean values. */
|
||||||
ifNotControlled: !apis.errorHandlers.ifControllable,
|
ifNotControlled: !apis.errorHandlers.ifControllable,
|
||||||
ifMini: apis.version.ifMini,
|
ifMini: apis.version.ifMini,
|
||||||
},
|
},
|
||||||
|
bgWindow,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user