2019-01-02 20:36:00 +01:00
|
|
|
import Comms from '../../ext/lib/comms/Comms';
|
|
|
|
|
|
|
|
class ExecAction {
|
|
|
|
constructor(settings) {
|
|
|
|
this.settings = settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
setSettings(settings) {
|
|
|
|
this.settings = settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
exec(action, scope, frame) {
|
|
|
|
for (var cmd of action.cmd) {
|
|
|
|
if (scope === 'page') {
|
|
|
|
const message = {
|
|
|
|
forwardToContentScript: true,
|
|
|
|
targetFrame: frame,
|
2019-01-20 20:36:24 +01:00
|
|
|
frame: frame,
|
2019-01-02 20:36:00 +01:00
|
|
|
cmd: cmd.action,
|
|
|
|
arg: cmd.arg
|
|
|
|
}
|
|
|
|
Comms.sendMessage(message);
|
|
|
|
} else if (scope === 'site') {
|
|
|
|
if (cmd.action === "set-stretch") {
|
|
|
|
this.settings.active.sites[window.location.host].stretch = cmd.arg;
|
|
|
|
} else if (cmd.action === "set-alignment") {
|
|
|
|
this.settings.active.sites[window.location.host].videoAlignment = cmd.arg;
|
|
|
|
} else if (cmd.action === "set-extension-mode") {
|
|
|
|
this.settings.active.sites[window.location.host].status = cmd.arg;
|
|
|
|
} else if (cmd.action === "set-autoar-mode") {
|
|
|
|
this.settings.active.sites[window.location.host].arStatus = cmd.arg;
|
|
|
|
}
|
|
|
|
this.settings.save();
|
|
|
|
} else if (scope === 'global') {
|
|
|
|
if (cmd.action === "set-stretch") {
|
2019-01-20 22:59:06 +01:00
|
|
|
this.settings.active.site['@global'].stretch = cmd.arg;
|
2019-01-02 20:36:00 +01:00
|
|
|
} else if (cmd.action === "set-alignment") {
|
2019-01-20 22:59:06 +01:00
|
|
|
this.settings.active.site['@global'].videoAlignment = cmd.arg;
|
2019-01-02 20:36:00 +01:00
|
|
|
} else if (cmd.action === "set-extension-mode") {
|
2019-01-20 22:59:06 +01:00
|
|
|
this.settings.active.sites['@global'] = cmd.arg;
|
2019-01-02 20:36:00 +01:00
|
|
|
} else if (cmd.action === "set-autoar-mode") {
|
2019-01-20 22:59:06 +01:00
|
|
|
this.settings.active.site['@global'].autoar.arStatus = cmd.arg;
|
2019-01-02 20:36:00 +01:00
|
|
|
}
|
|
|
|
this.settings.save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExecAction;
|