Last active
October 18, 2024 02:04
-
-
Save EldonMcGuinness/cbb211eb0be0023fb56e1dac2e8066e4 to your computer and use it in GitHub Desktop.
Set permission for apps on amazon kids+ content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Goto https://parents.amazon.com/explore?selectedContentType=APP | |
// Edit this to fit your family, each line is a child in your kids+ family and the order | |
// here show match the order listed when you click on an item to enable / disable it. | |
const child_defaults = [ | |
false, | |
false, | |
false, | |
false, | |
false, | |
]; | |
// -1 Ready | |
// 0 Stopping | |
// 1 Stopped | |
let appRun = -1; | |
let previousItem = 0; | |
function stopApp( item ){ | |
previousItem = item; | |
console.log("App Stopped"); | |
appRun = 1; | |
} | |
function sleep(s) { | |
return new Promise(resolve => setTimeout(resolve, s*1000)); | |
} | |
async function loadPages(){ | |
try { | |
//while( document.querySelector(".pd-margin-top .css-n0loux") ){ | |
console.log("Loading App Page"); | |
(document.querySelector(".pd-margin-top .css-n0loux")).click(); | |
await sleep(0.1); | |
while (document.querySelector('.css-6yd4xx')){ | |
if ( appRun == 0 ){ | |
break; | |
} | |
await sleep(0.1); | |
} | |
//} | |
}catch(e){ | |
} | |
console.log("Done!"); | |
} | |
async function closeWindow(){ | |
try { | |
document.querySelector('#modal-description').parentElement.parentElement.firstChild.click(); | |
}catch(e){ | |
} | |
} | |
async function changeChildSetting(child, show){ | |
const regex = ( show ) ? /hideButton/ : /showButton/; | |
try { | |
button = document.querySelector('#modal-description #pd-expl-detailcard-icon-'+child+' img'); | |
if (button.src.match( regex )) { | |
button.click(); | |
await sleep(0.3) | |
return true; | |
} | |
}catch(e){ | |
} | |
return false; | |
} | |
async function clicker( startAt = 0) { | |
console.log("Starting App"); | |
let currentItem = startAt; | |
let itemCount = 0; | |
// Get initial set of items | |
let items = document.querySelectorAll('.search-result-card-clickable'); | |
itemCount = items.length; | |
while ( currentItem < itemCount ) { | |
if ( appRun == 0 ){ | |
break; | |
} | |
console.log("Editing " + currentItem + " of " + itemCount ); | |
let button = null; | |
let changed = false; | |
items[currentItem].click(); | |
await sleep(0.25); | |
while( ! document.querySelector('#modal-description #pd-expl-detailcard-icon-0 img') ) { | |
if ( appRun == 0 ){ | |
break; | |
} | |
await sleep(0.1); | |
} | |
// Loop through the children and mark them as noted in the child_defaults variable | |
// true = shown | |
// false = hidden | |
for ( child in child_defaults ){ | |
let thisChanged = await changeChildSetting( child, child_defaults[child] ); | |
if ( ! changed ) { | |
changed = thisChanged; | |
} | |
} | |
if (changed){ | |
await sleep(1); | |
}else{ | |
} | |
currentItem++; | |
closeWindow(); | |
// Load more items | |
if ( currentItem == itemCount ) { | |
await loadPages(); | |
items = document.querySelectorAll('.search-result-card-clickable'); | |
itemCount = items.length; | |
//console.log("Count ["+currentItem+"]["+itemCount+"]"); | |
} | |
} | |
stopApp(currentItem); | |
console.log("Done!"); | |
} | |
document.addEventListener ("keydown", function (e) { | |
if (appRun == -1 && e.ctrlKey && e.altKey && e.key === "c") { // case sensitive | |
appRun = 0; | |
} | |
} ); | |
document.addEventListener ("keydown", function (e) { | |
if (appRun == 1 && e.ctrlKey && e.altKey && e.key === "r") { // case sensitive | |
appRun = -1; | |
clicker(previousItem); | |
} | |
} ); | |
clicker(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment