Skip to content

Commit

Permalink
Added redirect function on AB cloaking (#52)
Browse files Browse the repository at this point in the history
Added redirect function on AB cloaking
  • Loading branch information
dave9123 authored Jan 26, 2024
2 parents b699d26 + 22791e2 commit d364b3c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
40 changes: 19 additions & 21 deletions static/worksheets/api/abcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ window.addEventListener('load', function () {
const startScriptOnLoad = localStorage.getItem('startScriptOnLoad');

if (startScriptOnLoad === 'true') {
startScript();
}
});
var directPreviousPage = localStorage.getItem('directPreviousPage') || 'https://www.google.com/';
var currentURL = window.location.href;
var baseURL = currentURL.substring(0, currentURL.lastIndexOf("/") + 1);
var indexURL = baseURL + "main.html";

function startScript() {
var currentURL = window.location.href;
var baseURL = currentURL.substring(0, currentURL.lastIndexOf("/") + 1);
var indexURL = baseURL + "main.html";

win = window.open();
win.document.body.style.margin = "0";
win.document.body.style.height = "100vh";
var iframe = win.document.createElement("iframe");
iframe.style.border = "none";
iframe.style.width = "100%";
iframe.style.height = "100%";
iframe.style.margin = "0";
iframe.referrerpolicy = "no-referrer";
iframe.allow = "fullscreen";
iframe.src = indexURL;
win.document.body.appendChild(iframe);
}
win = window.open();
win.document.body.style.margin = "0";
win.document.body.style.height = "100vh";
var iframe = win.document.createElement("iframe");
iframe.style.border = "none";
iframe.style.width = "100%";
iframe.style.height = "100%";
iframe.style.margin = "0";
iframe.referrerpolicy = "no-referrer";
iframe.allow = "fullscreen";
iframe.src = indexURL;
win.document.body.appendChild(iframe);
this.window.location.replace(directPreviousPage);
}
});
13 changes: 13 additions & 0 deletions static/worksheets/api/abct.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const ABCCheckbox = document.getElementById('ABC');
const ABCDirect = document.getElementById('ABCDirect');

function handleCheckboxChange() {
const startScriptOnLoad = ABCCheckbox.checked;
Expand All @@ -12,14 +13,26 @@ function handleCheckboxChange() {
}
}

function handleTextChange() {
localStorage.setItem('directPreviousPage', ABCDirect.value);
console.log('ABC will direct to ' + ABCDirect.value + ' on page load.');
}

ABCDirect.addEventListener('change', handleTextChange);
ABCCheckbox.addEventListener('change', handleCheckboxChange);

window.addEventListener('load', () => {
const startScriptOnLoad = localStorage.getItem('startScriptOnLoad');
const directPreviousPage = localStorage.getItem('directPreviousPage');

if (startScriptOnLoad === 'true') {
ABCCheckbox.checked = true;
} else {
ABCCheckbox.checked = false;
}
if (directPreviousPage == null) {
ABCDirect.value = 'https://google.com/';
} else {
ABCDirect.value = directPreviousPage;
}
});
4 changes: 4 additions & 0 deletions static/worksheets/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ <h1>Panic Button</h1>
<h1>About Blank Toggle</h1>
<label for="ABC">Start ABC On Page Load?</label>
<input type="checkbox" id="ABC">
<br />
<label for="ABCDirect">Move To:</label>
<br />
<input type="text" id="ABCDirect">
</center>
</div>
</div>
Expand Down

0 comments on commit d364b3c

Please sign in to comment.