Advertisement
Guest User

Downvote All Entries on Telegram Contest

a guest
Oct 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function dislike(id) {
  2.     let op = {};
  3.     op.mode = 'no-cors';
  4.     op.method= 'POST';
  5.     op.headers = {'Content-Type': 'application/x-www-form-urlencoded'};
  6.     op.body = 'entry_id=xxx&method=dislikeEntry'.replace('xxx', id);
  7.     url = 'https://contest.com/api?hash=a5a66a44085823cbda';
  8.     return await fetch(url, op);
  9. }
  10.  
  11. const entries = document.querySelectorAll('.cd-entry-label');
  12. const entry_ids = [];
  13.  
  14. entries.forEach(node => entry_ids.push(node.innerText.replace(/[^#]*#/, '')));
  15.  
  16. entry_ids.forEach( async id => {
  17.     let r = await dislike(id);
  18.     let j = await r.json();
  19.     console.log(id + ' ' + j.state);
  20. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement