Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. function foundStickers(item) {
  2. // stringnick.pro
  3. const stickers = [];
  4. let stickerString = null;
  5. if (item && item.descriptions) {
  6. for (let k = 0; k < item.descriptions.length; k++) {
  7. if (item.descriptions[k].value.includes('sticker')) {
  8. stickerString = item.descriptions[k].value;
  9. break;
  10. }
  11. }
  12. }
  13. if (stickerString) {
  14. const regex = /<img width=64 height=48 src="(.*?)">/g;
  15. let m;
  16.  
  17. while ((m = regex.exec(stickerString)) !== null) {
  18. // This is necessary to avoid infinite loops with zero-width matches
  19. if (m.index === regex.lastIndex) {
  20. regex.lastIndex++;
  21. }
  22.  
  23.  
  24. m.forEach((match, groupIndex) => {
  25. if (groupIndex === 1) {
  26. stickers.push(match);
  27. }
  28. });
  29. }
  30. }
  31. return stickers;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement