Skip to content

Instantly share code, notes, and snippets.

@ngobach
Last active October 20, 2020 08:11
Show Gist options
  • Save ngobach/8ce4615a6130f89109e670841a4c23cf to your computer and use it in GitHub Desktop.
Save ngobach/8ce4615a6130f89109e670841a4c23cf to your computer and use it in GitHub Desktop.
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e=e||self).ss={})}(this,(function(e){"use strict";function o(e,o){return o?e+" #"+o:e}e.default={shareNative:function(e,t){void 0===e&&(e=document.title),void 0===t&&(t=""),navigator.share&&navigator.share({url:location.href,text:o(e,t)})},shareLINE:function(e,t){void 0===e&&(e=document.title),void 0===t&&(t=""),window.open("https://social-plugins.line.me/lineit/share?url="+encodeURIComponent(location.href)+"&text="+encodeURIComponent(o(e,t)))},shareFacebook:function(){window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(location.href))},shareTwitter:function(e,t){void 0===e&&(e=document.title),void 0===t&&(t=""),window.open("https://twitter.com/intent/tweet?url="+encodeURIComponent(location.href)+"&text="+encodeURIComponent(o(e,t)))}},Object.defineProperty(e,"__esModule",{value:!0})}));

Usage

ss.default.shareNative();
ss.default.shareFacebook();
ss.default.shareTwitter();
ss.default.shareLINE();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment