Skip to content

Commit

Permalink
Add Parler support
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-uva committed Dec 16, 2022
1 parent db8be3b commit 75ca146
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"js/zs-background.js",
"modules/tiktok.js",
"modules/instagram.js",
"modules/linkedin.js"
"modules/linkedin.js",
"modules/parler.js"
]
}
}
52 changes: 52 additions & 0 deletions modules/parler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
zeeschuimer.register_module(
'parler.com',
function (response, source_platform_url, source_url) {
let domain = source_platform_url.split('/')[2].toLowerCase().replace(/^www\./, '');
if (domain !== 'parler.com' && domain !== 'api.parler.com') {
return [];
}

if (source_url.indexOf('/trending/') !== -1) {
return [];
}

let data;
try {
data = JSON.parse(response);
} catch (SyntaxError) {
return [];
}

if ("data" in data) {
// search results "top results" (i.e. not the video tab)
let r = Object.values(data['data']);
let useable_items = [];
if (r.length === 0) {
return [];
}
let items = r.filter(x => x && x.hasOwnProperty('postuuid'));
let known_fields = ['body', 'user'];
for (let i in items) {
let item = items[i];
let item_ok = true;
for (let j in known_fields) {
if (!item.hasOwnProperty(known_fields[j])) {
item_ok = false;
}
}

if(item['ad']) {
item_ok = false;
}

if (item_ok) {
item['id'] = item['postuuid'];
useable_items.push(item);
}
}
return useable_items;
} else {
return [];
}
}
)

0 comments on commit 75ca146

Please sign in to comment.