Advertisement
Arxero

postImage final

May 9th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  <img id="postImage" alt="Image" class="postimage">
  2.     <script>
  3.         (function () {
  4.             let input = `{TEXT}`
  5.             let id = Date.now()
  6.             $('#postImage').attr('id', id)
  7.             let corsProxy = 'http://cors-proxy.htmldriven.com/?url='
  8.             //let input = `\n[url=https://postimg.cc/image/mk56q648t/][img]https://s14.postimg.cc/mk56q648t/free-steam-key_mini-ninjas.jpg[/img][/url]`
  9.             input = input.replace('\n', '')
  10.             let URL = input.split('][')[0].slice(5)
  11.             let urlProxied = corsProxy + URL
  12.             let pattern = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)(\.jpg|\.png|\.gif)/
  13.  
  14.             $.ajax({
  15.                 method: 'GET',
  16.                 url: urlProxied,
  17.             }).then(function (res) {
  18.                 let resString = JSON.stringify(res)
  19.                 let matches = resString.match(pattern)[0]
  20.                 $(`#${id}`).attr('src', matches).addClass('postimage')
  21.             })
  22.         }())
  23.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement