Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(page-type): display target label and page-type #67

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ function getFrzFlags() {
return document.body.dataset.frzFlags && JSON.parse(document.body.dataset.frzFlags);
}

function getTargetLabel() {
return document.body.dataset.frzTargetLabel;
}

function getPageType() {
const beaconScript = document.getElementById('frz-beacon-script');

return beaconScript ? beaconScript.getAttribute('data-page-type') || '' : 'Missing beacon script';
}

browser.runtime.onMessage.addListener((request, sender) => {
switch (request.action) {
case 'highlight_fragments':
Expand All @@ -49,6 +59,10 @@ browser.runtime.onMessage.addListener((request, sender) => {
case 'get_frz_flags':
return Promise.resolve(getFrzFlags());
break;
case 'get_target_label':
return Promise.resolve(getTargetLabel());
case 'get_page_type':
return Promise.resolve(getPageType());
default:
return Promise.reject('unexpected message');
}
Expand Down
10 changes: 9 additions & 1 deletion app/frz-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,18 @@ class FRZRequest {
getFrzFlags() {
return this.browserApi.tabs.sendMessage(this.details.tabId, { action: 'get_frz_flags' }).catch((e) => this.logError('get_frz_flags', e));
}

showLazyloadedImages() {
this.browserApi.tabs.sendMessage(this.details.tabId, { action: 'show_lazyloaded_image' }).catch((e) => this.logError('show_lazyloaded_image', e));
}

async getTargetLabel() {
return this.browserApi.tabs.sendMessage(this.details.tabId, { action: 'get_target_label' }).catch((e) => this.logError('get_target_label', e));
}

async getPageType() {
return this.browserApi.tabs.sendMessage(this.details.tabId, { action: 'get_page_type' }).catch((e) => this.logError('get_page_type', e));
}
}

// window.FRZRequest = FRZRequest;
56 changes: 42 additions & 14 deletions app/popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,7 @@ <h3><strong id="statusCode"></strong></h3>
/>
<hr>
<div id="optimized_options">

<div style="padding: 0px 10px; margin-bottom: 20px;">
<div class="checkbox">
<label>
<input
type="checkbox"
id="disable-fasterize-cache"
style="display:block!important"
/>
Bypass Fasterize cache for pages
</label>
</div>
</div>
<div style="text-align: left; width: 100%; padding: 0px 10px;">
<div style="padding: 0px 10px;">
<span style="margin-right: 20px;">
<label class="switch-xs" for="fstrz-espeed">
<input checked type="checkbox" id="fstrz-espeed" data-flag="fstrz-espeed">
Expand All @@ -58,6 +45,12 @@ <h3><strong id="statusCode"></strong></h3>
</label>
&nbsp;EdgeSEO
</span>
<div class="checkbox-inline" style="margin-left: 30px;">
<label>
<input type="checkbox" id="disable-fasterize-cache" />
Bypass Fasterize cache for pages
</label>
</div>
</div>

</div>
Expand Down Expand Up @@ -117,6 +110,41 @@ <h3><strong id="statusCode"></strong></h3>
></button>
</div>
</div>

<div class="input-group">
<div class="input-group-addon" style="width: 130px">
Page type
</div>
<input
id="page-type-fstrz"
class="form-control"
type="text"
/>
<div class="input-group-btn">
<button
data-copy-id="page-type-fstrz"
class="copy-button btn btn-primary octicon octicon-clippy"
title="Copy"
></button>
</div>
</div>
<div class="input-group">
<div class="input-group-addon" style="width: 130px">
Target
</div>
<input
id="target-fstrz"
class="form-control"
type="text"
/>
<div class="input-group-btn">
<button
data-copy-id="target-fstrz"
class="copy-button btn btn-primary octicon octicon-clippy"
title="Copy"
></button>
</div>
</div>
<div class="input-group">
<div class="input-group-addon" style="width: 130px">
Cookie fstrz
Expand Down
9 changes: 9 additions & 0 deletions app/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ function reloadPopup(tabID) {
})
.catch(logError);

request.getTargetLabel().then(targetLabel => {
$('#target-fstrz').val(targetLabel);
}).catch(logError);

request.getPageType().then(pageType => {
$('#page-type-fstrz').val(pageType);
}).catch(logError);


getDebugCookie(request.details.url)
.then(debugCookie => {
if (debugCookie && debugCookie.value === 'true') {
Expand Down