Skip to content

Generate a SVG button that allows you to get upvoted anywhere.

License

Notifications You must be signed in to change notification settings

akira-cn/upvote-anywhere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Upvote Anywhere

Generate a SVG button that allows you to get upvoted anywhere.

👁️‍🗨️ Generate my upvote button ⬆️

To be used in GitHub README

Do you like Upvote Anywhere? If you do, please give it an upvote.

To be used in Any Web App

Try it in CodePen

<img id="upvoteBtn" src="https://wp2aqcqkj5.us.aircode.run/show?id=64dc8e2885f13fbcd52be970" width="35" style="vertical-align: bottom;cursor:pointer;"> Do you like Upvote Anywhere? If you do, please give it an upvote.

<script>
upvoteBtn.addEventListener('click', async (event) => {
  event.preventDefault();
  await fetch('https://wp2aqcqkj5.us.aircode.run/upvote', {
    method: 'POST',
    headers: {
      'content-type': 'application/json',
    },
    body: JSON.stringify({id: '64dc8e2885f13fbcd52be970'}),
  });
  upvoteBtn.src = "https://wp2aqcqkj5.us.aircode.run/show?id=64dc8e2885f13fbcd52be970&t=" + Date.now();
});
</script>

Cookie Policy

Since Upvote Anywhere requires using cookies to track upvote status, when it's used on third-party websites and operated through fetch, it relies on the other party's CORS policy. For instance, CodePen's policy doesn't allow cross-site cookies, which means Upvote Anywhere can't record the voted status. However, we can use a GET request to https://wp2aqcqkj5.us.aircode.run/upvote to store the cookie on the original site, then redirect back to the target URL, just as we've done in our GitHub README.

Distribution

Upvote Anywhere is build on AirCode.

You can easily get a copy and launch your app on AirCode by clicking the button below.

Deploy with AirCode

About

Generate a SVG button that allows you to get upvoted anywhere.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published