import PluginBase from 'chrome-extension://lnnmjmalakahagblkkcnjkoaihlfglon/dist/modules/plugin-base.js';import ExtensionUtil from 'chrome-extension://lnnmjmalakahagblkkcnjkoaihlfglon/dist/modules/extension-util.js';const PAUSE_HOMOS = {
'potters': 'pause',
'paws': 'pause',
'pods': 'pause',
};
///
// The ID of the extension we want to talk to.
const SPEAK_ALOUD_EXT_ID = "hdhinadidafjejdhmfkjgnolgimiaplp";
const port = chrome.runtime.connect(SPEAK_ALOUD_EXT_ID);
// Make a simple request:
function sendCmdToSpeakAloud(command) {
checkForPermission().then(() => {
port.postMessage({ command, });
});
}
function checkForPermission() {
return new Promise(async (cb, reject) => {
const hasPerm = await PluginBase.getPluginOption('TTS', 'permission');
if (!hasPerm) {
const btn = document.createElement('button');
btn.textContent = 'Press this Button to Grant LipSurf necessary permissions for Read Aloud';
btn.setAttribute('style', 'pointer-events: all !important');
btn.id = 'TTS-perm';
btn.addEventListener('click', () => {
chrome.runtime.sendMessage(SPEAK_ALOUD_EXT_ID, { permissions: true, });
PluginBase.setPluginOption('TTS', 'permission', true);
const HUD = PluginBase.util.getHUDEl()[0];
HUD.removeChild(HUD.querySelector('#TTS-perm'));
});
PluginBase.util.getHUDEl()[0].appendChild(btn);
reject();
}
else {
cb();
}
});
}
var TTS = { ...PluginBase, ...{
niceName: 'Text to Speech',
languages: {},
description: 'Reads text aloud using a text-to-speech engine.',
version: '3.9.0',
// so this plugin gets priority on pdfs for things like
match: /.*/,
authors: "Miko",
homophones: {
...PAUSE_HOMOS,
},
contexts: {
'Read Aloud': {
commands: [
'Pause',
'Resume',
'Stop',
]
}
},
init: function () {
port.onMessage.addListener(function (msg) {
if (msg === 'end')
PluginBase.util.enterContext(['Normal']);
});
},
commands: [
{
name: 'Speak It',
description: 'Say the currently selected text, or the text inside the active text area.',
match: ['[speak/say/read] [it/aloud]'],
fn: () => PluginBase.util.enterContext(['Read Aloud']),
pageFn: () => {
sendCmdToSpeakAloud('play');
}
},
{
name: 'Pause',
match: 'pause',
pageFn: () => {
sendCmdToSpeakAloud('play');
}
},
{
name: 'Resume',
match: ['resume', 'play'],
pageFn: () => {
sendCmdToSpeakAloud('play');
}
},
{
name: 'Stop',
match: ['stop', 'exit'],
fn: () => PluginBase.util.enterContext(['Normal']),
pageFn: () => {
sendCmdToSpeakAloud('stop');
},
}
]
} };
export default TTS;LS-SPLITallPlugins.TTS = (() => { ///
// The ID of the extension we want to talk to.
const SPEAK_ALOUD_EXT_ID = "hdhinadidafjejdhmfkjgnolgimiaplp";
const port = chrome.runtime.connect(SPEAK_ALOUD_EXT_ID);
// Make a simple request:
function sendCmdToSpeakAloud(command) {
checkForPermission().then(() => {
port.postMessage({ command, });
});
}
function checkForPermission() {
return new Promise(async (cb, reject) => {
const hasPerm = await PluginBase.getPluginOption('TTS', 'permission');
if (!hasPerm) {
const btn = document.createElement('button');
btn.textContent = 'Press this Button to Grant LipSurf necessary permissions for Read Aloud';
btn.setAttribute('style', 'pointer-events: all !important');
btn.id = 'TTS-perm';
btn.addEventListener('click', () => {
chrome.runtime.sendMessage(SPEAK_ALOUD_EXT_ID, { permissions: true, });
PluginBase.setPluginOption('TTS', 'permission', true);
const HUD = PluginBase.util.getHUDEl()[0];
HUD.removeChild(HUD.querySelector('#TTS-perm'));
});
PluginBase.util.getHUDEl()[0].appendChild(btn);
reject();
}
else {
cb();
}
});
}
var TTS = { ...PluginBase, ...{
init: function () {
port.onMessage.addListener(function (msg) {
if (msg === 'end')
PluginBase.util.enterContext(['Normal']);
});
},
commands: {
"Speak It": {
pageFn: () => {
sendCmdToSpeakAloud('play');
}
},
"Pause": {
pageFn: () => {
sendCmdToSpeakAloud('play');
}
},
"Resume": {
pageFn: () => {
sendCmdToSpeakAloud('play');
}
},
"Stop": {
pageFn: () => {
sendCmdToSpeakAloud('stop');
}
}
}
} };
return TTS;
})()LS-SPLITallPlugins.TTS = (() => { ///
// The ID of the extension we want to talk to.
const SPEAK_ALOUD_EXT_ID = "hdhinadidafjejdhmfkjgnolgimiaplp";
const port = chrome.runtime.connect(SPEAK_ALOUD_EXT_ID);
var TTS = { ...PluginBase, ...{
init: function () {
port.onMessage.addListener(function (msg) {
if (msg === 'end')
PluginBase.util.enterContext(['Normal']);
});
},
commands: {}
} };
return TTS;
})()