-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ceaf8a0
Showing
16 changed files
with
779 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.zip | ||
*.pem | ||
*.crx |
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,18 @@ | ||
Copyright 2017 Stephen Zhang <zsrkmyn at gmail dot com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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 @@ | ||
PROJECT_NAME=ingress-opr-helper | ||
|
||
distribute: | ||
zip -r ${PROJECT_NAME}.zip ${PROJECT_NAME} |
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,39 @@ | ||
#opr-helper-map-container, | ||
#opr-helepr-config-position-config-helper-and-css-sucks { | ||
position: relative; | ||
} | ||
|
||
#opr-helper-map { | ||
height: 300px; | ||
} | ||
|
||
#opr-helper-panorama { | ||
height: 300px; | ||
} | ||
|
||
#opr-helper-config { | ||
position: absolute; | ||
padding: 3px 5px 3px 5px; | ||
top: 3px; | ||
left: 3px; | ||
background: #ffffff; | ||
opacity: 0.8; | ||
color: #000; | ||
font-size: 12px; | ||
font-family: sans-serif; | ||
font-weight: normal; | ||
} | ||
|
||
#opr-helper-config label { | ||
margin: 0; | ||
} | ||
|
||
#opr-helper-config select { | ||
display: inline; | ||
} | ||
|
||
#opr-helper-config input[type="checkbox"] { | ||
margin: 0 2px 0 2px; | ||
vertical-align: middle; | ||
} | ||
|
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,41 @@ | ||
body { | ||
min-width: 200px; | ||
} | ||
|
||
h1 { | ||
font-family: sans-serif; | ||
font-size: 20px; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
|
||
h2 { | ||
font-family: sans-serif; | ||
font-size: 15px; | ||
font-weight: bold; | ||
} | ||
|
||
.menu { | ||
margin: 5px; | ||
} | ||
|
||
.group { | ||
margin: 5px; | ||
} | ||
|
||
.group > section { | ||
font-family: sans-serif; | ||
font-size: 13px; | ||
margin: 10px 7px 10px 7px; | ||
} | ||
|
||
.group > section > input[type="checkbox"] { | ||
margin: 0 5px 0 0; | ||
vertical-align: middle; | ||
} | ||
|
||
.separator { | ||
margin: 5px; | ||
border-style: solid; | ||
border-width: 1px; | ||
} |
Loading
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,33 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "Ingress OPR Helper", | ||
"version": "0.1", | ||
"description": "A helper for ingress portal recon system", | ||
"icons": {"128": "images/icon128.png"}, | ||
"permissions": ["storage"], | ||
"background": { | ||
"scripts": ["scripts/bg.js"] | ||
}, | ||
"content_security_policy": "script-src 'self' https://webapi.amap.com; object-src 'self'", | ||
"web_accessible_resources": [ | ||
"scripts/map.js", | ||
"scripts/utils.js", | ||
"scripts/amap.js", | ||
"scripts/baidu.js" | ||
], | ||
"browser_action": { | ||
"default_title": "", | ||
"default_icon": "images/icon128.png", | ||
"default_popup": "popup.html" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["https://opr.ingress.com/recon"], | ||
"js": [ | ||
"scripts/main.js", | ||
"scripts/provider.js" | ||
], | ||
"css": ["css/map.css"] | ||
} | ||
] | ||
} |
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,40 @@ | ||
<html> | ||
<head> | ||
<link href="css/popup.css" rel="stylesheet"> | ||
<script type="text/javascript" src="scripts/provider.js"></script> | ||
<script type="text/javascript" src="scripts/popup.js"></script> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Ingress OPR Helper</h1> | ||
</header> | ||
<div class="menu"> | ||
<div class="separator"></div> | ||
<div class="group"> | ||
<h2>Layers</h2> | ||
<section><input type="checkbox" id="satellite"><label>Show satellite map</label></section> | ||
<section><input type="checkbox" id="road"><label>Show road map</label></section> | ||
</div> | ||
<div class="separator"></div> | ||
<div class="group"> | ||
<h2>Misc</h2> | ||
<section><input type="checkbox" id="fixchina"><label>Fix offset in China</label></section> | ||
</div> | ||
<div class="separator"></div> | ||
<div class="group"> | ||
<h2>Provider</h2> | ||
<section> | ||
<label>Choose provider:</label> | ||
<select id="provider"> | ||
</select> | ||
</section> | ||
</div> | ||
<div class="separator"></div> | ||
</div> | ||
<footer> | ||
<center> | ||
<a href="https://github.com/zsrkmyn/ingress-opr-helper" target="_blank">About</a> | ||
</center> | ||
</footer> | ||
</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,65 @@ | ||
{ | ||
let AMAP_URL = "https://webapi.amap.com/maps?v=1.3&key=bf3417f86991b12f5b64466f7e0498a0"; | ||
let OPRHelperAMap = class extends OPRHelperMap { | ||
constructor(mapid, settings) { | ||
super(mapid); | ||
window.map = this.map = new AMap.Map( | ||
settings.mcontainer, | ||
{showIndoorMap: false} | ||
); | ||
AMap.plugin(['AMap.ToolBar', 'AMap.Scale'], () => { | ||
this.map.addControl(new AMap.ToolBar({ | ||
position: 'RB', | ||
liteStyle: true, | ||
direction: false, | ||
})); | ||
this.map.addControl(new AMap.Scale()); | ||
}) | ||
this.ready(); | ||
} | ||
|
||
setZoom(z) { | ||
this.map.setZoom(z); | ||
} | ||
|
||
setCenter(lng, lat) { | ||
this.map.setCenter([lng, lat]); | ||
} | ||
|
||
addMarker(lng, lat, icon, offset) { | ||
var opt = { | ||
map: this.map, | ||
position: [lng, lat], | ||
} | ||
if (icon) { | ||
opt.icon = icon; | ||
if (offset) | ||
opt.offset = new AMap.Pixel(offset[0], offset[1]); | ||
} | ||
var marker = new AMap.Marker(opt); | ||
marker.show(); | ||
} | ||
|
||
showSatellite(flag) { | ||
if (!this.satellite) | ||
this.satellite = new AMap.TileLayer.Satellite( | ||
{map: this.map, opacity: 1}); | ||
if (flag == undefined || flag) | ||
this.satellite.show(); | ||
else | ||
this.satellite.hide(); | ||
} | ||
|
||
showRoad(flag) { | ||
if (!this.road) | ||
this.road = new AMap.TileLayer.RoadNet( | ||
{map: this.map, opacity: 1}); | ||
if (flag == undefined || flag) | ||
this.road.show(); | ||
else | ||
this.road.hide(); | ||
} | ||
} | ||
|
||
OPRHelperMapFactory.register('amap', OPRHelperAMap, () => loadScript(AMAP_URL)); | ||
} |
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,130 @@ | ||
{ | ||
let BMAP_URL = "https://api.map.baidu.com/api?v=2.0&ak=gfXoaMam8YmLlPZ05kKUw7C7CLykEn3T&s=1"; | ||
let OPRHelperBaiduMap = class extends OPRHelperMap { | ||
constructor(mapid, settings) { | ||
super(mapid); | ||
this.road = false; | ||
this.satellite = false; | ||
this.pcontainer = settings.pcontainer; | ||
this.map = new BMap.Map(settings.mcontainer); | ||
this.map.centerAndZoom(new BMap.Point(116, 39), 15); // fuck baidu! map won't work if centerAndZoom isn't called | ||
this.map.enableScrollWheelZoom(); | ||
this.map.enableContinuousZoom(); | ||
this.map.addControl(new BMap.NavigationControl({ | ||
anchor: BMAP_ANCHOR_BOTTOM_RIGHT, | ||
type: BMAP_NAVIGATION_CONTROL_ZOOM, | ||
})); | ||
this.map.addControl(new BMap.ScaleControl({ | ||
anchor: BMAP_ANCHOR_BOTTOM_LEFT, | ||
})); | ||
this.ready() | ||
} | ||
|
||
setZoom(z) { | ||
this.map.setZoom(z); | ||
} | ||
|
||
setCenter(lng, lat) { | ||
[lng, lat] = OPRHelperBaiduMap.mars2baidu(lng, lat); | ||
this.map.setCenter(new BMap.Point(lng, lat)); | ||
} | ||
|
||
addMarker(lng, lat, icon, offset) { | ||
[lng, lat] = OPRHelperBaiduMap.mars2baidu(lng, lat); | ||
var pos = new BMap.Point(lng, lat); | ||
var opt = {} | ||
if (icon) { | ||
opt.icon = new BMap.Icon(icon); | ||
} | ||
var marker = new BMap.Marker(pos, opt); | ||
this.map.addOverlay(marker); | ||
} | ||
|
||
showSatellite(flag) { | ||
var mapType; | ||
if (flag === undefined || flag) { | ||
this.satellite = true; | ||
if (this.road) | ||
mapType = BMAP_HYBRID_MAP; | ||
else | ||
mapType = BMAP_SATELLITE_MAP; | ||
} else { | ||
this.satellite = false; | ||
mapType = BMAP_NORMAL_MAP; | ||
} | ||
this.map.setMapType(mapType); | ||
} | ||
|
||
showRoad(flag) { | ||
var mapType = BMAP_NORMAL_MAP; | ||
if (flag === undefined || flag) { | ||
this.road = true; | ||
if (this.satellite) | ||
mapType = BMAP_HYBRID_MAP; | ||
} else { | ||
this.road= false; | ||
if (this.satellite) | ||
mapType = BMAP_SATELLITE_MAP; | ||
} | ||
this.map.setMapType(mapType); | ||
} | ||
|
||
showPanorama(lng, lat) { | ||
[lng, lat] = OPRHelperBaiduMap.mars2baidu(lng, lat); | ||
OPRHelperBaiduMap.getPanoramaInfo(lng, lat) | ||
.then((data) => { | ||
if (!this.panorama) { | ||
this.panorama = | ||
new BMap.Panorama(this.pcontainer, { | ||
navigationControl: true, | ||
linksControl: true, | ||
}); | ||
} | ||
var pos = new BMap.Point(lng, lat); | ||
this.panorama.setPosition(pos); | ||
this.panorama.addOverlay( | ||
new BMap.PanoramaLabel( | ||
'Portal Here', | ||
{position: pos} | ||
) | ||
); | ||
this.panorama.show(); | ||
}); | ||
} | ||
|
||
static getPanoramaInfo(lng, lat) { | ||
return new Promise((resolve, reject) => { | ||
var service = new BMap.PanoramaService(); | ||
service.getPanoramaByLocation(new BMap.Point(lng, lat), | ||
(data) => { | ||
if (data == null) | ||
reject(); | ||
else | ||
resolve(data); | ||
}); | ||
}); | ||
} | ||
|
||
// stolen from http://blog.csdn.net/coolypf/article/details/8569813 | ||
static mars2baidu(lng, lat) { | ||
const xpi = 3.14159265358979324 * 3000.0 / 180.0; | ||
var z = Math.sqrt(lng * lng + lat * lat) + 2e-5 * Math.sin(lat * xpi); | ||
var theta = Math.atan2(lat, lng) + 3e-6 * Math.cos(lng * xpi); | ||
return [ | ||
z * Math.cos(theta) + 0.0065, // lng | ||
z * Math.sin(theta) + 0.006 // lat | ||
]; | ||
} | ||
} | ||
|
||
OPRHelperMapFactory.register('baidu', OPRHelperBaiduMap, () => { | ||
return new Promise((resolve, reject) => { | ||
BMAP_URL += '&callback=window.onbmapload_'; | ||
window.onbmapload_ = () => { | ||
delete window.onbmapload_; | ||
setTimeout(resolve, 2000); | ||
} | ||
loadScript(BMAP_URL); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.