Skip to content

Commit

Permalink
Merge pull request #2 from manojVivek/master
Browse files Browse the repository at this point in the history
Syncing my fork
  • Loading branch information
romanakash committed Jun 1, 2020
2 parents a41c7f1 + 3bc8e36 commit fbfb5e5
Show file tree
Hide file tree
Showing 37 changed files with 913 additions and 177 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Expand Up @@ -58,6 +58,15 @@
"contributions": [
"code"
]
},
{
"login": "romanakash",
"name": "Roman Akash",
"avatar_url": "https://avatars1.githubusercontent.com/u/40427975?v=4",
"profile": "https://github.com/romanakash",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
5 changes: 3 additions & 2 deletions README.md
@@ -1,6 +1,6 @@
# Responsively App ![Twitter Follow](https://img.shields.io/twitter/follow/ResponsivelyApp?style=social)
# Responsively App ![Twitter Follow](https://img.shields.io/twitter/follow/ResponsivelyApp?style=social) [![xscode](https://img.shields.io/badge/Available%20on-xs%3Acode-blue?style=?style=plastic&logo=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////////VXz1bAAAAAJ0Uk5T/wDltzBKAAAAlUlEQVR42uzXSwqAMAwE0Mn9L+3Ggtgkk35QwcnSJo9S+yGwM9DCooCbgn4YrJ4CIPUcQF7/XSBbx2TEz4sAZ2q1RAECBAiYBlCtvwN+KiYAlG7UDGj59MViT9hOwEqAhYCtAsUZvL6I6W8c2wcbd+LIWSCHSTeSAAECngN4xxIDSK9f4B9t377Wd7H5Nt7/Xz8eAgwAvesLRjYYPuUAAAAASUVORK5CYII=)](https://xscode.com/manojvivek/responsively-app)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
[![PH](https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=200375&theme=light&period=daily)](https://www.producthunt.com/posts/responsively?utm_source=badge-top-post-badge&utm_medium=badge&utm_souce=badge-responsively)

Expand Down Expand Up @@ -68,6 +68,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/leon0707"><img src="https://avatars1.githubusercontent.com/u/523684?v=4" width="100px;" alt=""/><br /><sub><b>Leon Feng</b></sub></a><br /><a href="https://github.com/manojVivek/responsively-app/commits?author=leon0707" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/kishoreio"><img src="https://avatars2.githubusercontent.com/u/30261988?v=4" width="100px;" alt=""/><br /><sub><b>Kishore S</b></sub></a><br /><a href="https://github.com/manojVivek/responsively-app/commits?author=kishoreio" title="Code">💻</a></td>
<td align="center"><a href="https://jjavierdguezas.github.io"><img src="https://avatars2.githubusercontent.com/u/13673443?v=4" width="100px;" alt=""/><br /><sub><b>José Javier Rodríguez Zas</b></sub></a><br /><a href="https://github.com/manojVivek/responsively-app/commits?author=jjavierdguezas" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/romanakash"><img src="https://avatars1.githubusercontent.com/u/40427975?v=4" width="100px;" alt=""/><br /><sub><b>Roman Akash</b></sub></a><br /><a href="https://github.com/manojVivek/responsively-app/commits?author=romanakash" title="Code">💻</a></td>
</tr>
</table>

Expand Down
5 changes: 5 additions & 0 deletions browser-extension/.gitignore
@@ -0,0 +1,5 @@
node_modules
yarn.lock
dist
setCreds.sh
web-ext-artifacts
4 changes: 4 additions & 0 deletions browser-extension/.vscode/settings.json
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
66 changes: 66 additions & 0 deletions browser-extension/package.json
@@ -0,0 +1,66 @@
{
"name": "Responsively-Helper",
"version": "0.0.1",
"description": "An extension to open current browser page in Responsively app",
"private": true,
"scripts": {
"lint": "run-p lint:*",
"lint:js": "xo",
"lint:css": "stylelint source/**/*.css",
"lint-fix": "run-p 'lint:* -- --fix'",
"test": "run-s lint:* build",
"build": "webpack --mode=production",
"start": "webpack --mode=development --watch",
"release:cws": "webstore upload --source=dist --auto-publish",
"release:amo": "web-ext-submit --source-dir dist",
"release": "run-s build release:*"
},
"devDependencies": {
"@babel/core": "^7.10.1",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-proposal-object-rest-spread": "^7.10.1",
"@babel/plugin-transform-react-constant-elements": "^7.10.1",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/preset-env": "^7.10.1",
"@babel/preset-react": "^7.10.1",
"@ianwalter/web-ext-webpack-plugin": "^0.1.0",
"babel-loader": "^8.1.0",
"chrome-webstore-upload-cli": "^1.2.0",
"copy-webpack-plugin": "^5.0.3",
"daily-version": "^0.12.0",
"dot-json": "^1.1.0",
"eslint": "^6.1.0",
"eslint-config-xo": "^0.26.0",
"npm-run-all": "^4.1.5",
"size-plugin": "^1.2.0",
"stylelint": "^10.1.0",
"stylelint-config-xo": "^0.15.0",
"terser-webpack-plugin": "^1.3.0",
"web-ext": "^4.2.0",
"web-ext-submit": "^4.2.0",
"webpack": "^4.36.1",
"webpack-cli": "^3.3.6",
"xo": "^0.24.0"
},
"dependencies": {
"custom-protocol-check": "^1.1.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"url-loader": "^4.1.0",
"webextension-polyfill": "^0.4.0"
},
"xo": {
"envs": [
"browser"
],
"ignores": [
"dist"
],
"globals": [
"browser"
]
},
"stylelint": {
"extends": "stylelint-config-xo"
}
}
Binary file added browser-extension/public/logo_128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added browser-extension/public/logo_16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added browser-extension/public/logo_48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions browser-extension/public/manifest.json
@@ -0,0 +1,27 @@
{
"name": "Responsively Helper",
"version": "0.0.1",
"description": "An extension to open current browser page in Responsively app",
"homepage_url": "https://manojvivek.github.io/responsively-app",
"manifest_version": 2,
"icons": {
"128": "logo_128.png",
"48": "logo_48.png",
"16": "logo_16.png"
},
"background": {
"persistent": false,
"scripts": [
"browser-polyfill.min.js",
"background.js"
]
},
"browser_action": {
"default_icon": "logo_128.png",
"default_title": "Open page in Responsively app",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
]
}
68 changes: 68 additions & 0 deletions browser-extension/public/popup.html
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<style>
body {
margin: 0;
overflow: hidden;
width: 340px;
background-color: #1d1b26;
box-sizing: border-box;
}

.header {
display: flex;
justify-content: center;
margin: 10px 0 20px;
}

.logo {
height: 48px;
}

.anchorButton {
color: #fd2d55;
border-color: #fd2d55;
display: flex;
justify-content: center;
border: 1px solid;
padding: 5px;
border-radius: 3px;
text-decoration: none;
}

.popup {
height: 200px;
color: #fff;
padding: 25px;
}

.flexCenter {
display: flex;
justify-content: center;
align-items: center;
}

.textJustify {
text-align: justify;
}

.loadingSpinner {
height: 50px;
}
</style>
<script src="browser-polyfill.min.js"></script>
</head>
<body>
<div class="header">
<img class="logo" src="logo_128.png" alt="Responsively App" />
</div>
<div id="app"></div>
<script src="popup.js"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions browser-extension/src/background.js
@@ -0,0 +1,5 @@
browser.browserAction.onClicked.addListener((tab) => {
browser.tabs.executeScript({
file: './openURL.js'
});
});
135 changes: 135 additions & 0 deletions browser-extension/src/popup.js
@@ -0,0 +1,135 @@
import openCustomProtocolURI from "custom-protocol-check";
import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom";
import spinner from "./spinner.svg";

const isChrome = () => {
// IE11 returns undefined for window.chrome
// and new Opera 30 outputs true for window.chrome
// but needs to check if window.opr is not undefined
// and new IE Edge outputs to true for window.chrome
// and if not iOS Chrome check
const isChromium = window.chrome;
const winNav = window.navigator;
const vendorName = winNav.vendor;
const isOpera = typeof window.opr !== "undefined";
const isIEedge = winNav.userAgent.indexOf("Edge") > -1;
const isIOSChrome = winNav.userAgent.match("CriOS");
return (
(isChromium !== null &&
typeof isChromium !== "undefined" &&
vendorName === "Google Inc." &&
isOpera === false &&
isIEedge === false) ||
isIOSChrome
);
};

const URLOpenerNonChrome = () => {
const [status, setStatus] = useState("loading");
useEffect(() => {
(async () => {
const [tab] = await window.browser.tabs.query({
currentWindow: true,
active: true,
});
if (!tab || !tab.url) {
setStatus("false");
return;
}
openCustomProtocolURI(
`responsively://${tab.url}`,
() => {
setStatus("false");
},
() => {
setStatus("true");
}
);
})();
}, []);

if (status === "loading") {
return (
<div className="popup">
<div className="flexCenter">
<img className="loadingSpinner" src={spinner} />
</div>
</div>
);
}
if (status === "false") {
return (
<div className="popup">
<div className="textJustify">
It looks like you dont have Responsively App installed to preview the
page in responsive mode.
</div>
<br />
<br />
<br />
Please install the app and open it once to continue using the extension.
<br />
<div className="flexCenter">
<a
className="anchorButton"
onClick={() => setTimeout(() => window.close(), 200)}
href="https://manojvivek.github.io/responsively-app/"
target="_blank"
>
Install Now
</a>
</div>
</div>
);
}
return null;
};

const URLOpenerChrome = () => {
useEffect(() => {
(async () => {
const [tab] = await window.browser.tabs.query({
currentWindow: true,
active: true,
});
if (!tab || !tab.url) {
return;
}
window.browser.tabs.update({
url: `responsively://${tab.url}`,
});
})();
return setTimeout(() => {
window.close();
}, 5000);
}, []);

return (
<div className="popup">
<div className="textJustify">
If you have any issues seeing the responsive preview, please make sure
Responsively app is installed.
</div>
<br />
<br />
<div className="flexCenter">
<a
className="anchorButton"
onClick={() => setTimeout(() => window.close(), 200)}
href="https://manojvivek.github.io/responsively-app/"
target="_blank"
>
Install Now
</a>
</div>
<br />
<br />
</div>
);
};

ReactDOM.render(
isChrome() ? <URLOpenerChrome /> : <URLOpenerNonChrome />,
document.getElementById("app")
);

0 comments on commit fbfb5e5

Please sign in to comment.