add option for iframe popups

This commit is contained in:
siikamiika 2020-04-05 01:43:12 +03:00
parent 0d76cef434
commit 31a326fe63
5 changed files with 19 additions and 3 deletions

View File

@ -108,7 +108,8 @@
"enableClipboardMonitor", "enableClipboardMonitor",
"showPitchAccentDownstepNotation", "showPitchAccentDownstepNotation",
"showPitchAccentPositionNotation", "showPitchAccentPositionNotation",
"showPitchAccentGraph" "showPitchAccentGraph",
"showIframePopupsInRootFrame"
], ],
"properties": { "properties": {
"enable": { "enable": {
@ -242,6 +243,10 @@
"showPitchAccentGraph": { "showPitchAccentGraph": {
"type": "boolean", "type": "boolean",
"default": false "default": false
},
"showIframePopupsInRootFrame": {
"type": "boolean",
"default": false
} }
} }
}, },

View File

@ -127,7 +127,8 @@ function profileOptionsCreateDefaults() {
enableClipboardMonitor: false, enableClipboardMonitor: false,
showPitchAccentDownstepNotation: true, showPitchAccentDownstepNotation: true,
showPitchAccentPositionNotation: true, showPitchAccentPositionNotation: true,
showPitchAccentGraph: false showPitchAccentGraph: false,
showIframePopupsInRootFrame: false
}, },
audio: { audio: {

View File

@ -87,6 +87,7 @@ async function formRead(options) {
options.general.showPitchAccentDownstepNotation = $('#show-pitch-accent-downstep-notation').prop('checked'); options.general.showPitchAccentDownstepNotation = $('#show-pitch-accent-downstep-notation').prop('checked');
options.general.showPitchAccentPositionNotation = $('#show-pitch-accent-position-notation').prop('checked'); options.general.showPitchAccentPositionNotation = $('#show-pitch-accent-position-notation').prop('checked');
options.general.showPitchAccentGraph = $('#show-pitch-accent-graph').prop('checked'); options.general.showPitchAccentGraph = $('#show-pitch-accent-graph').prop('checked');
options.general.showIframePopupsInRootFrame = $('#show-iframe-popups-in-root-frame').prop('checked');
options.general.popupTheme = $('#popup-theme').val(); options.general.popupTheme = $('#popup-theme').val();
options.general.popupOuterTheme = $('#popup-outer-theme').val(); options.general.popupOuterTheme = $('#popup-outer-theme').val();
options.general.customPopupCss = $('#custom-popup-css').val(); options.general.customPopupCss = $('#custom-popup-css').val();
@ -167,6 +168,7 @@ async function formWrite(options) {
$('#show-pitch-accent-downstep-notation').prop('checked', options.general.showPitchAccentDownstepNotation); $('#show-pitch-accent-downstep-notation').prop('checked', options.general.showPitchAccentDownstepNotation);
$('#show-pitch-accent-position-notation').prop('checked', options.general.showPitchAccentPositionNotation); $('#show-pitch-accent-position-notation').prop('checked', options.general.showPitchAccentPositionNotation);
$('#show-pitch-accent-graph').prop('checked', options.general.showPitchAccentGraph); $('#show-pitch-accent-graph').prop('checked', options.general.showPitchAccentGraph);
$('#show-iframe-popups-in-root-frame').prop('checked', options.general.showIframePopupsInRootFrame);
$('#popup-theme').val(options.general.popupTheme); $('#popup-theme').val(options.general.popupTheme);
$('#popup-outer-theme').val(options.general.popupOuterTheme); $('#popup-outer-theme').val(options.general.popupOuterTheme);
$('#custom-popup-css').val(options.general.customPopupCss); $('#custom-popup-css').val(options.general.customPopupCss);

View File

@ -174,6 +174,10 @@
<label><input type="checkbox" id="show-pitch-accent-graph"> Show graph for pitch accents</label> <label><input type="checkbox" id="show-pitch-accent-graph"> Show graph for pitch accents</label>
</div> </div>
<div class="checkbox options-advanced">
<label><input type="checkbox" id="show-iframe-popups-in-root-frame"> Show iframe popups in root frame</label>
</div>
<div class="checkbox options-advanced"> <div class="checkbox options-advanced">
<label><input type="checkbox" id="show-debug-info"> Show debug information</label> <label><input type="checkbox" id="show-debug-info"> Show debug information</label>
</div> </div>

View File

@ -22,6 +22,7 @@
* PopupProxy * PopupProxy
* PopupProxyHost * PopupProxyHost
* apiForward * apiForward
* apiOptionsGet
*/ */
async function main() { async function main() {
@ -30,8 +31,11 @@ async function main() {
const data = window.frontendInitializationData || {}; const data = window.frontendInitializationData || {};
const {id, depth=0, parentFrameId, url, proxy=false} = data; const {id, depth=0, parentFrameId, url, proxy=false} = data;
const optionsContext = {depth, url};
const options = await apiOptionsGet(optionsContext);
let popup; let popup;
if (!proxy && (window !== window.parent)) { if (!proxy && (window !== window.parent) && options.general.showIframePopupsInRootFrame) {
const rootPopupInformationPromise = yomichan.getTemporaryListenerResult( const rootPopupInformationPromise = yomichan.getTemporaryListenerResult(
chrome.runtime.onMessage, chrome.runtime.onMessage,
({action, params}, {resolve}) => { ({action, params}, {resolve}) => {