├── README.md ├── tweet-this.js ├── index.html └── .github └── workflows └── static.yml /README.md: -------------------------------------------------------------------------------- 1 | # tweet-this 2 | A bookmarklet to tweet the current document, highlight text as the tweet. 3 | 4 | Drag it from [here](https://codepo8.github.io/tweet-this/) to your toolbars 5 | -------------------------------------------------------------------------------- /tweet-this.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let d = document; 3 | let t = d.title; 4 | let u = d.location.href; 5 | var s = window.getSelection().getRangeAt(0).cloneContents(); 6 | var tw = d.createTreeWalker(s, NodeFilter.SHOW_TEXT); 7 | var c = ''; 8 | while (tw.nextNode()) { 9 | c = c.concat(treeWalker.currentNode.nodeValue); 10 | } 11 | let out = encodeURIComponent(`👉🏼 „${t}”\n🔗${u}\n💬 ${c}`); 12 | console.log(`[${t}](${u})\n${c}`); 13 | navigator.clipboard.writeText(snippet); 14 | window.open(`https://twitter.com/intent/tweet?text=${out}`); 15 | })(); 16 | 17 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Tweet this 8 | 17 | 18 | 19 |

Tweet this

20 |

A bookmarklet to tweet the current page. Highlight any text and hit it and you can tweet in the format of:

21 |
22 | 
23 | “Tweet text”
24 | 
25 | https://example.com
26 | 
27 | 
28 |

Drag this to your bookmarks toolbar: tweet this

29 | 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/static.yml: -------------------------------------------------------------------------------- 1 | # Simple workflow for deploying static content to GitHub Pages 2 | name: Deploy static content to Pages 3 | 4 | on: 5 | # Runs on pushes targeting the default branch 6 | push: 7 | branches: ["master"] 8 | 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 13 | permissions: 14 | contents: read 15 | pages: write 16 | id-token: write 17 | 18 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 19 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 20 | concurrency: 21 | group: "pages" 22 | cancel-in-progress: false 23 | 24 | jobs: 25 | # Single deploy job since we're just deploying 26 | deploy: 27 | environment: 28 | name: github-pages 29 | url: ${{ steps.deployment.outputs.page_url }} 30 | runs-on: ubuntu-latest 31 | steps: 32 | - name: Checkout 33 | uses: actions/checkout@v3 34 | - name: Setup Pages 35 | uses: actions/configure-pages@v3 36 | - name: Upload artifact 37 | uses: actions/upload-pages-artifact@v1 38 | with: 39 | # Upload entire repository 40 | path: '.' 41 | - name: Deploy to GitHub Pages 42 | id: deployment 43 | uses: actions/deploy-pages@v2 44 | --------------------------------------------------------------------------------