Skip to content

Instantly share code, notes, and snippets.

@kentbrew
Last active December 29, 2015 21:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kentbrew/7727982 to your computer and use it in GitHub Desktop.
Save kentbrew/7727982 to your computer and use it in GitHub Desktop.
Invite your readers to leave you a Bitcoin tip on Reddit

###Invite your readers to leave you a Bitcoin tip on Reddit

Reddit's Bitcoin implementation is ideal for beginners. Here's how to get them to give it a try.

####Structure

Put this in the structure of your page, right where you want the button to appear:

<a class="tipMeOnReddit" href="http://www.reddit.com/message/compose?to=bitcointip&subject=Tip&message=%2B/u/bitcointip%20%40kentbrew%201%20beer">
  <img title="Buy me a beer on Reddit!" src="http://thumbs.reddit.com/t5_2saz1.png" />
  Like what you're reading? Buy me a beer on Reddit!
</a>

Be sure to change my username to yours, or I'll be collecting your beer. Also feel free to change the suggested tip to whatever you like, but be sure to percent-encode it properly.

####Presentation

Put this in the <head> of your page, integrate it with your existing style, or roll your own:

<style>
  a.tipMeOnReddit {
    height: 60px;
    font-size: 12px;
    font-family: Verdana, arial, sans-serif;
    padding: 7px 12px 7px 0;
    background: #eee;
    border: 1px solid #666;
    border-radius: 3px;
    box-shadow: 0 0 10px #666;
    text-decoration: none;
    color: #666;
  }
  a.tipMeOnReddit img {
    vertical-align: middle;
  }
</style>

####Behavior

The button will work fine without this script, which is what causes the pop-up window to appear, and automatically inserts the page URL into the message, so you have some idea where the tip came from.

Put this at the bottom of your page, as close to the closing </body> tag as possible:

<script>
(function(w, d){
  var a = d.getElementsByTagName('A');
  for (var i = 0, n = a.length; i < n; i = i + 1) {
    if (a[i].href && a[i].className && a[i].className === 'tipMeOnReddit') {
      a[i].href = a[i].href.replace(/Tip/, 'Tip for ' + encodeURIComponent(d.URL));
      a[i].onclick = function () {
        w.open(this.href, '_tipme', 'width=550,height=500');
        return false;
      };
    }
  }
}(window, document)); 
</script>
@kentbrew
Copy link
Author

kentbrew commented Dec 2, 2013

Discussion is on Reddit's /r/bitcointip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment