Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from manojVivek/master
Syncing my fork
- Loading branch information
Showing
37 changed files
with
913 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
yarn.lock | ||
dist | ||
setCreds.sh | ||
web-ext-artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
browser.browserAction.onClicked.addListener((tab) => { | ||
browser.tabs.executeScript({ | ||
file: './openURL.js' | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
); |
Oops, something went wrong.