Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
add option for iframe popups
Browse files Browse the repository at this point in the history
  • Loading branch information
siikamiika committed Apr 4, 2020
1 parent 320d63c commit 9b87a55
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ext/bg/data/options-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"customPopupCss",
"customPopupOuterCss",
"enableWanakana",
"enableClipboardMonitor"
"enableClipboardMonitor",
"showIframePopupsInRootFrame"
],
"properties": {
"enable": {
Expand Down Expand Up @@ -227,6 +228,10 @@
"enableClipboardMonitor": {
"type": "boolean",
"default": false
},
"showIframePopupsInRootFrame": {
"type": "boolean",
"default": false
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion ext/bg/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ function profileOptionsCreateDefaults() {
customPopupCss: '',
customPopupOuterCss: '',
enableWanakana: true,
enableClipboardMonitor: false
enableClipboardMonitor: false,
showIframePopupsInRootFrame: false
},

audio: {
Expand Down
2 changes: 2 additions & 0 deletions ext/bg/js/settings/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ async function formRead(options) {
options.general.popupScalingFactor = parseFloat($('#popup-scaling-factor').val());
options.general.popupScaleRelativeToPageZoom = $('#popup-scale-relative-to-page-zoom').prop('checked');
options.general.popupScaleRelativeToVisualViewport = $('#popup-scale-relative-to-visual-viewport').prop('checked');
options.general.showIframePopupsInRootFrame = $('#show-iframe-popups-in-root-frame').prop('checked');
options.general.popupTheme = $('#popup-theme').val();
options.general.popupOuterTheme = $('#popup-outer-theme').val();
options.general.customPopupCss = $('#custom-popup-css').val();
Expand Down Expand Up @@ -161,6 +162,7 @@ async function formWrite(options) {
$('#popup-scaling-factor').val(options.general.popupScalingFactor);
$('#popup-scale-relative-to-page-zoom').prop('checked', options.general.popupScaleRelativeToPageZoom);
$('#popup-scale-relative-to-visual-viewport').prop('checked', options.general.popupScaleRelativeToVisualViewport);
$('#show-iframe-popups-in-root-frame').prop('checked', options.general.showIframePopupsInRootFrame);
$('#popup-theme').val(options.general.popupTheme);
$('#popup-outer-theme').val(options.general.popupOuterTheme);
$('#custom-popup-css').val(options.general.customPopupCss);
Expand Down
4 changes: 4 additions & 0 deletions ext/bg/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ <h3>General Options</h3>
<label><input type="checkbox" id="popup-scale-relative-to-visual-viewport"> Change popup size relative to page viewport</label>
</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">
<label><input type="checkbox" id="show-debug-info"> Show debug information</label>
</div>
Expand Down
6 changes: 5 additions & 1 deletion ext/fg/js/frontend-initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* PopupProxy
* PopupProxyHost
* apiForward
* apiOptionsGet
*/

async function main() {
Expand All @@ -30,8 +31,11 @@ async function main() {
const data = window.frontendInitializationData || {};
const {id, depth=0, parentFrameId, url, proxy=false} = data;

const optionsContext = {depth, url};
const options = await apiOptionsGet(optionsContext);

let popup;
if (!proxy && (window !== window.parent)) {
if (!proxy && (window !== window.parent) && options.general.showIframePopupsInRootFrame) {
const rootPopupInformationPromise = yomichan.getTemporaryListenerResult(
chrome.runtime.onMessage,
({action, params}, {resolve}) => {
Expand Down

0 comments on commit 9b87a55

Please sign in to comment.