Browse Source

Handle permissions parsing failure

master
KaKi87 3 weeks ago
parent
commit
b3947dd259
2 changed files with 19 additions and 12 deletions
  1. 4
    1
      gplay.js
  2. 15
    11
      public/assets/js/index.js

+ 4
- 1
gplay.js View File

@@ -22,7 +22,10 @@ module.exports = {
GPlay.permissions({ appId: app.appId }).then(permissions => {
app.permissions = permissions;
resolve();
}).catch(resolve);
}).catch(() => {
app.permissions = null;
resolve();
});
}))).then(() => callback(apps)));
})
.catch(err => console.log(err));

+ 15
- 11
public/assets/js/index.js View File

@@ -139,22 +139,26 @@ searchButton.onclick = () => {
const displayedPermissions = [];
res.forEach(app => {
// Show all permissions
app.permissions.forEach(permission => {
const p = permission.permission;
const d = permission.description;
if(displayedPermissions.indexOf(p) === -1){
displayedPermissions.push(p);
document.querySelector('.output2__data').innerHTML += `<tr class="output2__permission"><th class="output2__permission__name" data-uk-tooltip="title: ${d}; pos: right">${p}</th></tr>`;
}
});
if(Array.isArray(app.permissions)){
app.permissions.forEach(permission => {
const p = permission.permission;
const d = permission.description;
if(displayedPermissions.indexOf(p) === -1){
displayedPermissions.push(p);
document.querySelector('.output2__data').innerHTML += `<tr class="output2__permission"><th class="output2__permission__name" data-uk-tooltip="title: ${d}; pos: right">${p}</th></tr>`;
}
});
}
document.querySelector('.output2__header tr').innerHTML += `<th class="output2__app">${app.title}</th>`;
// Show apps details
document.querySelector('.output__data').innerHTML += `<tr class="output__item" data-link="${app.url}"><td class="output__data__name" data-uk-tooltip="title: ${app.developer}; delay: 500; pos: right"><img class="output__icon" src="${app.icon}" alt="${app.title}">${app.title} <span class="output__data__index">${app.index}</span></td><td class="output__data__description">${app.summary}</td><td class="output__data__installs">${app.minInstalls.toLocaleString('en-US')}</td><td class="output__data__score" data-uk-tooltip="title: ${app.ratings} ratings; delay: 500; pos: right">${app.score.toFixed(1)}</td><td class="output__data__size">${app.size.endsWith('k') ? `0.${app.size.slice(0, -1)}M` : app.size}</td><td class="output__data__version">${app.version}</td><td class="output__data__last-update" data-date=${app.updated}">${new Date(app.updated).toDateString()}</td><td class="output__data__price">${app.priceText}</td><td class="output__data__ads">${app.adSupported}</td><td class="output__data__IAP">${app.offersIAP}</td><td class="output__data__android-version">${app.androidVersion}</td><td class="output__data__permissions">${app.permissions.length}</td></tr>`;
document.querySelector('.output__data').innerHTML += `<tr class="output__item" data-link="${app.url}"><td class="output__data__name" data-uk-tooltip="title: ${app.developer}; delay: 500; pos: right"><img class="output__icon" src="${app.icon}" alt="${app.title}">${app.title} <span class="output__data__index">${app.index}</span></td><td class="output__data__description">${app.summary}</td><td class="output__data__installs">${app.minInstalls ? app.minInstalls.toLocaleString('en-US') : 'N/A'}</td><td class="output__data__score" data-uk-tooltip="title: ${app.ratings} ratings; delay: 500; pos: right">${app.score ? app.score.toFixed(1) : 'N/A'}</td><td class="output__data__size">${app.size ? (app.size.endsWith('k') ? `0.${app.size.slice(0, -1)}M` : app.size) : 'N/A'}</td><td class="output__data__version">${app.version}</td><td class="output__data__last-update" data-date=${app.updated}">${app.updated ? new Date(app.updated).toDateString() : 'N/A'}</td><td class="output__data__price">${app.priceText}</td><td class="output__data__ads">${app.adSupported}</td><td class="output__data__IAP">${app.offersIAP}</td><td class="output__data__android-version">${app.androidVersion}</td><td class="output__data__permissions">${Array.isArray(app.permissions) ? app.permissions.length : 'N/A'}</td></tr>`;
});
res.forEach(app => {
// Show permissions per app
for(let i = 0; i < displayedPermissions.length; i++){
document.querySelectorAll('.output2__permission')[i].innerHTML += `<td>${app.permissions.map(p => p.permission).indexOf(displayedPermissions[i]) !== -1 ? '•' : ''}</td>`;
if(Array.isArray(app.permissions)){
for(let i = 0; i < displayedPermissions.length; i++){
document.querySelectorAll('.output2__permission')[i].innerHTML += `<td>${app.permissions.map(p => p.permission).indexOf(displayedPermissions[i]) !== -1 ? '•' : ''}</td>`;
}
}
});
// Display tables

Loading…
Cancel
Save