From 3f6adff6d9428f9066709ee3fe1a071cabdfea8b Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sat, 15 Apr 2017 19:53:01 -0700 Subject: [PATCH] Adds support for StackExchange sites --- dist/manifest.json | 13 ++++++++++++- dist/scripts/main.js | 4 ++++ dist/styles/main.css | 20 +++++++++++++++----- src/scripts/main.js | 4 ++++ src/styles/main.scss | 20 +++++++++++++++++--- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/dist/manifest.json b/dist/manifest.json index 3c7de24..98989b6 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -18,6 +18,17 @@ "content_scripts": [{ "css": ["styles/main.css"], "js": ["scripts/main.js"], - "matches": ["https://github.com/*"] + "matches": [ + "https://github.com/*", + "http://stackexchange.com/*", + "https://stackexchange.com/*", + "http://*.stackexchange.com/*", + "https://*.stackexchange.com/*", + "https://serverfault.com/*", + "https://superuser.com/*", + "https://askubuntu.com/*", + "http://stackoverflow.com/*", + "https://stackoverflow.com/*" + ] }] } diff --git a/dist/scripts/main.js b/dist/scripts/main.js index c622f14..0c4c1c4 100644 --- a/dist/scripts/main.js +++ b/dist/scripts/main.js @@ -784,6 +784,10 @@ var snippets = document.querySelectorAll('pre'); parent.replaceChild(wrapper, snippet); wrapper.appendChild(snippet); + if (document.location.hostname === 'github.com') { + wrapper.classList.add('codecopy-github'); + } + wrapper.classList.add('codecopy'); wrapper.firstChild.insertAdjacentHTML('beforebegin', ''); }); diff --git a/dist/styles/main.css b/dist/styles/main.css index 8328e61..6a5f7d9 100644 --- a/dist/styles/main.css +++ b/dist/styles/main.css @@ -467,17 +467,27 @@ .codecopy .BtnGroup-form:hover + .BtnGroup-form .BtnGroup-item { border-left-width: 0; } .codecopy .codecopy-btn { + box-shadow: none; + min-height: initial; transition: opacity 0.3s ease-in-out; opacity: 0; - padding: 3px 6px; position: absolute; - right: 5px; - top: 5px; } + padding: 2px 6px; + right: 0; + top: 0; } .codecopy .codecopy-btn .codecopy-btn-icon { margin-top: -3px; position: relative; - top: 3px; } - .codecopy .codecopy-btn:focus { + top: 3px; + padding: 0; + vertical-align: initial; + min-height: initial; } + .codecopy .codecopy-btn:hover, .codecopy .codecopy-btn:focus { box-shadow: none; } .codecopy:hover .codecopy-btn { opacity: 1; } + +.codecopy.codecopy-github .codecopy-btn { + padding: 3px 6px; + right: 5px; + top: 5px; } diff --git a/src/scripts/main.js b/src/scripts/main.js index 1cf2674..2d02ff9 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -9,6 +9,10 @@ let snippets = document.querySelectorAll('pre'); parent.replaceChild(wrapper, snippet); wrapper.appendChild(snippet); + if (document.location.hostname === 'github.com') { + wrapper.classList.add('codecopy-github'); + } + wrapper.classList.add('codecopy'); wrapper.firstChild.insertAdjacentHTML('beforebegin', ''); }); diff --git a/src/styles/main.scss b/src/styles/main.scss index d271aff..1e8f099 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -9,20 +9,28 @@ @extend .btn; @extend .btn-sm; + box-shadow: none; + min-height: initial; + transition: opacity 0.3s ease-in-out; opacity: 0; - padding: 3px 6px; position: absolute; - right: 5px; - top: 5px; + padding: 2px 6px; + right: 0; + top: 0; .codecopy-btn-icon { margin-top: -3px; position: relative; top: 3px; + + padding: 0; + vertical-align: initial; + min-height: initial; } + &:hover, &:focus { box-shadow: none; } @@ -32,3 +40,9 @@ opacity: 1; } } + +.codecopy.codecopy-github .codecopy-btn { + padding: 3px 6px; + right: 5px; + top: 5px; +}