Skip to content

Commit

Permalink
Merge pull request #1 from scaryuncledevin/master
Browse files Browse the repository at this point in the history
Cleaned up script injections and added an options page.
  • Loading branch information
wolfd committed Nov 7, 2014
2 parents 1d578e9 + d080dc0 commit fdcc638
Show file tree
Hide file tree
Showing 8 changed files with 401 additions and 41 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
this is terrible
----------------
but it got me a Nexus 6 after awhile

PLEASE OPEN THE OPTIONS PAGE TO SET YOUR PUSHBULLET API KEY AND SELECT DEVICES
15 changes: 0 additions & 15 deletions insertion.js

This file was deleted.

49 changes: 28 additions & 21 deletions iwantnexus.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions jquery.min.js

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "I want nexus",
"description": "I want nexus",
"version": "0.0.1",
"version": "0.0.2",
"content_scripts": [
{
"matches": ["https://play.google.com/store/devices/*"],
"js": ["insertion.js"]
"js": ["jquery.min.js","pushbullet.js","iwantnexus.js"]
}
],
"web_accessible_resources": [
"iwantnexus.js"
],
"options_page": "options.html",
"permissions": ["storage"],
"manifest_version": 2
}
45 changes: 45 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<title>I Want A Nexus 6 Options</title>
</head>
<link href="reset.css" type="text/css" rel="stylesheet">
<style>
body {
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
color:#000000;
background-color:#FFFFFF;
padding:5px;
}

strong {
font-weight:bold;
}
</style>
<body>

<div>
<label for="refresh_interval"><strong>Refresh Interval (ms):</strong></label>
<input type="text" id="refresh_interval">
</div>
<br>
<div>
<label for="api_key"><strong>Pushbullet Access Token:</strong></label>
<a href="https://www.pushbullet.com/account" target="_blank">?</a>
<input type="text" id="api_key" size="50">
</div>
<br>
<div id="devices">
Enter your Pushbullet Access Token above and click save to view available devices for notifications to be pushed to.
</div>
<br>
<button id="save">Save</button>
<button id="test">Test</button>

</body>
</html>

<script src="jquery.min.js"></script>
<script src="pushbullet.js"></script>
<script src="options.js"></script>
58 changes: 58 additions & 0 deletions options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
var devices = [];

$("#save").click(function(e) {
devices = [];
$(".devices").filter(':checked').each(function(index, element) {
devices.push($(element).val());
});

chrome.storage.sync.set({
refresh_interval: $("#refresh_interval").val(),
api_key: $("#api_key").val(),
devices: devices
});

PushBullet.APIKey = $("#api_key").val();
load_devices(devices);
});

chrome.storage.sync.get({
api_key: '',
devices:[],
refresh_interval:1000
}, function(items) {
$("#api_key").val(items.api_key);
$("#refresh_interval").val(items.refresh_interval);
PushBullet.APIKey = items.api_key;
devices = items.devices;
load_devices();
});

function load_devices()
{
$("#devices").empty().append(
$("<div>").append("DO NOT SELECT CHROME DEVICES OR YOU MAY END UP IN A NEVERENDING LOOP")
);
PushBullet.devices(function(err, res) {
if(err) {
throw err;
} else {
$.each(res.devices, function(index, device)
{
$("#devices").append(
$("<div>").append(
$("<input>").attr("type", "checkbox").addClass("devices").attr("id",device.iden).val(device.iden).prop('checked', devices.indexOf(device.iden) !== -1)
).append(
$("<label>").attr("for",device.iden).append(device.nickname)
)
);
});
}
});
}

$("#test").click(function(e){
$.each(devices, function(index, device_iden){
PushBullet.push("link", device_iden, null, {title: "I got you a Nexus 6", url: "https://www.google.com/"});
});
});
Loading

0 comments on commit fdcc638

Please sign in to comment.