Advertisement
Arxero

postImage finished but cleaned

May 9th, 2018
403
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).attr('src', 'https://i.imgur.com/gEGNc1v.gif')
  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.                 //$('#preview div').find('.content').append($('<img>').attr('src', matches).attr('alt', 'Image').addClass('postimage').attr('style', 'max-width: 815px; border: 3px solid transparent; border-radius: 6px; transition: border-color 0.1s ease-out; cursor: pointer;'))
  21.                 let output = `\n[img]${matches}[/img]`
  22.                 //let textAreaValue = $('#message').val()
  23.                 //$('#message').val(textAreaValue += output)
  24.                 //console.log(textAreaValue)
  25.                 $(`#${id}`).attr('src', matches).addClass('postimage')
  26.             })
  27.         }())
  28.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement