mvan231

NHL Draft Deadline Widget

Apr 11th, 2021
622
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let date = new Date(1618254000000)
  2.  
  3.  
  4. let w = new ListWidget()
  5.  
  6. let timeStack = w.addStack()
  7. let countD = timeStack.addDate(date)
  8. countD.applyTimerStyle()
  9. timeStack.addText(' remaining')
  10.  
  11. let dF = new DateFormatter()
  12. dF.dateFormat='MMMM dd'
  13. let today = dF.string(new Date()).toUpperCase()
  14. log(today)
  15.  
  16. let url = 'https://www.nhl.com/news/2020-21-nhl-trades/c-289968698'
  17.  
  18. let r = new Request(url)
  19. let res = await r.loadString()
  20. // log(res)
  21. let reg = `(${today})\:\&nbsp\;\<\/b(.*?)<\/span`
  22. //log(reg)
  23. reg= RegExp(reg,'g')
  24. //log(reg)
  25. let reg2 = RegExp(reg,'')
  26. // log(reg2)
  27. let regRes = res.match(reg)
  28. //log(regRes)
  29. if (regRes){
  30. regRes.forEach((f) => {
  31.   log(f)
  32.   let fMatch = f.match(reg2)[2]
  33. //   log(fMatch)
  34.   fMatch = fMatch.replace(/<.*?>/g,'')
  35. //   log(fMatch)
  36.   let newT = w.addText(fMatch)
  37.   newT.minimumScaleFactor = 0.75
  38.   newT.lineLimit=2
  39.   }
  40. )
  41. }else{
  42.   w.addText('no new drafts today')
  43. }
  44. Script.setWidget(w)
  45. Script.complete()
  46. w.presentMedium()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×