Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. javascript: (function () {
  2.  
  3.     /* check if the counter exists. */
  4.     if (window.googlePlusOneFloatingCounter == null) {
  5.         window.googlePlusOneFloatingCounter = 0;
  6.     }
  7.  
  8.     /* check if previous +1 button already exists. */
  9.     var appLabel = "__googleplusonefloating__";
  10.     var id = appLabel + window.googlePlusOneFloatingCounter;
  11.     var doc = document;
  12.     var x = doc.getElementById(id);
  13.     if (x != null) {
  14.         x.disapear();
  15.         window.googlePlusOneFloatingCounter++;
  16.     }
  17.  
  18.     /* create new id for wrapper div. */
  19.     id = appLabel + window.googlePlusOneFloatingCounter;
  20.  
  21.     /* create a wrapper div. */
  22.     var div = doc.createElement('div');
  23.     div.id = id;
  24.     div.style.position = "absolute";
  25.     div.style.background = "white";
  26.     div.style.top = "" + (pageYOffset + 100) + "px";
  27.     div.style.left = "-200px";
  28.     div.style.height = "20px";
  29.     div.style.width = "150px";
  30.     div.style.zIndex = "9999";
  31.     div.style.boxShadow = "0 0 7px black";
  32.     div.style.borderRadius = "10px";
  33.     div.style.padding = "10px";
  34.     div.style.webkitTransition = "1500ms";
  35.     div.style.MozTransition = "1500ms";
  36.     div.style.textAlign = "center";
  37.  
  38.     /* set +1 button source code. */
  39.     div.innerHTML = "<div style='float: right'><g:plusone size='medium' href='" + location.href + "'></g:plusone><br /><br /></div>";
  40.  
  41.     /* set disapearing action. */
  42.     div.disapear = function () {
  43.         var self = this;
  44.         self.style.left = '-200px';
  45.         setTimeout(function () {
  46.             self.parentElement.removeChild(self);
  47.         }, 2000);
  48.     };
  49.  
  50.     /* create a close button. */
  51.     var close = doc.createElement('button');
  52.     close.innerHTML = '&nbsp;&laquo;&nbsp;';
  53.     close.style.position = "relative";
  54.     close.style.float = 'left';
  55.     close.style.boxShadow = "0 0 3px black";
  56.     close.style.color = "white";
  57.     close.style.borderRadius = "5px";
  58.     close.style.border = "solid 0px";
  59.     close.style.background = "black";
  60.     close.style.margin = "0 7px 0 7px";
  61.     close.style.padding = "0";
  62.     close.style.width = "35px";
  63.     close.style.height = "20px";
  64.     close.style.fontFamily = '"Lucida Grande","Hiragino Kaku Gothic Pro","ヒラギノ角ゴ Pro W3","MS Pゴシック",Verdana,Arial,sans-serif';
  65.  
  66.     /* set the close button action.
  67.    listener refers to closure's div. */
  68.     close.addEventListener('click', function () {
  69.         div.disapear();
  70.     });
  71.  
  72.     /* insert the close button into the wrapper. */
  73.     div.insertBefore(close, div.firstChild);
  74.  
  75.     /* Asynchronously import +1 button JavaScript.
  76.        It parse +1 tag and convert it into dom. */
  77.     setTimeout(function () {
  78.         var po = doc.createElement('script');
  79.         po.type = 'text/javascript';
  80.         po.async = true;
  81.         po.src = 'https://apis.google.com/js/plusone.js';
  82.         doc.getElementsByTagName('body')[0].appendChild(po);
  83.  
  84.         /* after setting the import code, trigger the transition of the wrapper div. */
  85.         setTimeout(function () {
  86.             div.style.left = "100px";
  87.         }, 30);
  88.     }, 30);
  89.  
  90.     /* append wrapper div to body */
  91.     document.body.appendChild(div);
  92.  
  93. })();