├── .gitignore ├── README.md ├── assets └── how_to_use.gif └── simple-url-copy ├── icons ├── 128.png ├── 16.png ├── 32.png ├── 64.png └── icon4store.png ├── manifest.json ├── popup.css ├── popup.html └── popup.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.crx 2 | *.pem 3 | *.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Simple URL Copy 2 | A Chrome extension that help you to copy URL 3 | 4 | ## Install 5 | https://chrome.google.com/webstore/detail/cefkgjbbpagcilodnhboolbppdjlplip 6 | 7 | ## Features 8 | - Simple and Fast 9 | - It can copy as markdown style. 10 | - It can copy as [Backlog](https://www.backlog.com/) style. 11 | - It can copy and open menu by shotcut(ctrl+shift+c) 12 | - It can exclude query strings, and trim Japanese Amazon's verbose URL. 13 | 14 | ## Demo 15 | ![demo](https://github.com/ikedaosushi/simple-url-copy/blob/master/assets/how_to_use.gif) 16 | -------------------------------------------------------------------------------- /assets/how_to_use.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikedaosushi/simple-url-copy/e1cd23b4c9ec6f4d3611c1d67b97c4b3697bd61f/assets/how_to_use.gif -------------------------------------------------------------------------------- /simple-url-copy/icons/128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikedaosushi/simple-url-copy/e1cd23b4c9ec6f4d3611c1d67b97c4b3697bd61f/simple-url-copy/icons/128.png -------------------------------------------------------------------------------- /simple-url-copy/icons/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikedaosushi/simple-url-copy/e1cd23b4c9ec6f4d3611c1d67b97c4b3697bd61f/simple-url-copy/icons/16.png -------------------------------------------------------------------------------- /simple-url-copy/icons/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikedaosushi/simple-url-copy/e1cd23b4c9ec6f4d3611c1d67b97c4b3697bd61f/simple-url-copy/icons/32.png -------------------------------------------------------------------------------- /simple-url-copy/icons/64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikedaosushi/simple-url-copy/e1cd23b4c9ec6f4d3611c1d67b97c4b3697bd61f/simple-url-copy/icons/64.png -------------------------------------------------------------------------------- /simple-url-copy/icons/icon4store.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikedaosushi/simple-url-copy/e1cd23b4c9ec6f4d3611c1d67b97c4b3697bd61f/simple-url-copy/icons/icon4store.png -------------------------------------------------------------------------------- /simple-url-copy/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simple URL Copy", 3 | "description": "Helps to copy url with various formats", 4 | "author": "@ikedaosushi", 5 | "version": "1.0.0.3", 6 | "manifest_version": 2, 7 | "icons": { 8 | "16": "icons/16.png", 9 | "128": "icons/128.png" 10 | }, 11 | "browser_action": { 12 | "default_popup": "popup.html", 13 | "default_icon": "icons/16.png" 14 | }, 15 | "commands": { 16 | "_execute_browser_action": { 17 | "suggested_key": { 18 | "default": "Ctrl+Shift+C", 19 | "mac": "MacCtrl+Shift+C" 20 | }, 21 | "description": "Opens popup.html" 22 | } 23 | }, 24 | "permissions": ["tabs"], 25 | "content_security_policy": "script-src 'self' https://code.getmdl.io; object-src 'self'", 26 | "devtools_page": "popup.html" 27 | } -------------------------------------------------------------------------------- /simple-url-copy/popup.css: -------------------------------------------------------------------------------- 1 | body { 2 | width: 330px; 3 | } 4 | .demo-card-square > .mdl-card__title { 5 | color: white; 6 | background-color: #00b8ac; 7 | } 8 | .mdl-button { 9 | display: inline; 10 | text-transform: none; 11 | padding: 0; 12 | line-height: 20px; 13 | } 14 | 15 | .mdl-card__actions { 16 | padding: 8px 16px; 17 | /* width: 91%; */ 18 | } 19 | 20 | .bettercopy-checkbox { 21 | display: inline-block; 22 | width: 47%; 23 | } 24 | 25 | .mdl-switch__label { 26 | color: #0000008a; 27 | font-size: 12px; 28 | left: 16px; 29 | } 30 | 31 | .bettercopy-menu { 32 | cursor: pointer; 33 | } 34 | 35 | .bettercopy-copy { 36 | cursor: none; 37 | margin: 0; 38 | padding: 0; 39 | } 40 | 41 | .bettercopy-textarea{ 42 | display: block; 43 | padding: 5px; 44 | width: 97%; 45 | height: 50px; 46 | line-height: 18px; 47 | overflow: auto; 48 | word-break: break-all; 49 | text-align: left; 50 | background-color: #00bcab7a; 51 | font-size: 10px; 52 | cursor: text; 53 | } 54 | 55 | #copied { 56 | margin: 0 0 0 20px; 57 | opacity: 1; 58 | transition-property: opacity; 59 | transition-duration: 0s; 60 | } 61 | 62 | #copied.invisible { 63 | opacity: 0; 64 | transition: 2s; 65 | } -------------------------------------------------------------------------------- /simple-url-copy/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Simple URL Copy 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |

Simple URL Copy

18 |
19 |
20 | Ctrl+Shift+C can open this menu. 21 | 22 |
23 |
24 |
25 | 29 |
30 |
31 |
32 | 33 | Title URL 34 | 35 |
36 |
37 | 38 | Title
URL 39 |
40 |
41 |
42 | 43 | Markdown Style 44 | 45 |
46 |
47 | 48 | Backlog Style 49 | 50 |
51 |
52 | 53 |
54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /simple-url-copy/popup.js: -------------------------------------------------------------------------------- 1 | 2 | const AMAZON_HOST = "www.amazon.co.jp"; 3 | 4 | let stores = { 5 | "excludeQuery": false 6 | } 7 | 8 | const copyText = text => { 9 | let copyTextArea = document.querySelector("#copy-textarea"); 10 | copyTextArea.textContent = text; 11 | copyTextArea.select(); 12 | document.execCommand('copy'); 13 | } 14 | 15 | const extractAmazonUrl = rawUrl => { 16 | const url = new URL(rawUrl); 17 | if (url.host == AMAZON_HOST && url.pathname.match(/\/dp\/[A-Za-z0-9]+\//)) { 18 | newUrl = url.origin + url.pathname.replace(/(^\S+)(\/dp\/[A-Za-z0-9]+\/)(.*)/, '$2'); 19 | return newUrl; 20 | } else { 21 | return rawUrl; 22 | } 23 | } 24 | 25 | const excludeQuery = rawUrl => { 26 | const url = new URL(rawUrl); 27 | const newUrl = url.origin + url.pathname; 28 | return newUrl; 29 | } 30 | 31 | const showCopied = _ => { 32 | let copied = document.querySelector("#copied"); 33 | copied.classList.remove("invisible"); 34 | setTimeout(_ => copied.classList.add("invisible"), 500); 35 | } 36 | 37 | const copyUrl = menuType => { 38 | chrome.tabs.query({ active: true, currentWindow: true, lastFocusedWindow: true }, function (tabs) { 39 | let url = tabs[0].url; 40 | const title = tabs[0].title; 41 | 42 | // Process AmazonURL 43 | url = extractAmazonUrl(url); 44 | 45 | // Process Query 46 | if(stores.excludeQuery) { 47 | url = excludeQuery(url); 48 | } 49 | 50 | let text; 51 | switch (menuType) { 52 | case "markdown": 53 | text = `[${title}](${url})` 54 | break; 55 | case "backlog": 56 | text = `[[${title}:${url}]]` 57 | break; 58 | case "simple": 59 | text = `${title} ${url}` 60 | break; 61 | case "with-newline": 62 | text = `${title}\n${url}` 63 | break; 64 | } 65 | copyText(text); 66 | showCopied(); 67 | }) 68 | } 69 | 70 | const onInit = _ => { 71 | // First copy simple 72 | copyUrl("simple"); 73 | document.querySelectorAll(".bettercopy-menu").forEach(el => { 74 | el.addEventListener("click", onClickCopyMenu); 75 | }); 76 | document.querySelector("#switchExcludeQuery") 77 | .addEventListener("click", onClickSwitchExcludeQuery); 78 | } 79 | 80 | const onClickSwitchExcludeQuery = evt => { 81 | stores.excludeQuery = evt.srcElement.checked; 82 | console.log(evt.srcElement.checked); 83 | } 84 | 85 | const onClickCopyMenu = function(evt){ 86 | const menuType = this.id; 87 | copyUrl(menuType); 88 | } 89 | 90 | document.addEventListener("DOMContentLoaded", onInit); --------------------------------------------------------------------------------