Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Plugin/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var message;
browser.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
message = msg;
sendResponse("Gotcha!");
});
28 changes: 18 additions & 10 deletions Plugin/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
} else {
createWeb3();
}
document.getElementById("setNet").addEventListener("click", setNetwork);
document.getElementById("loginButton").addEventListener("click", Login);
document.getElementById("completeFields").addEventListener("click", CompleteFields);
document.getElementById("submitButton").addEventListener("click", SubmitToBlockchain);
document.getElementById("checkButton").addEventListener("click", CheckIntegrity);


function SubmitToBlockchain (){

Expand Down Expand Up @@ -56,8 +62,8 @@
var nonce = "0x" + (nonceValue).toString(16);
rawtx = {
nonce: nonce,
gasPrice: this.web3.utils.toHex(estimatedGas),
gasLimit: this.web3.utils.toHex(GasLimit),
gasPrice: web3.utils.toHex(estimatedGas),
gasLimit: web3.utils.toHex(GasLimit),
to: contractAddress,
data: bytecodeData
};
Expand All @@ -67,7 +73,7 @@
tx.sign(privateKey);
var raw = "0x" + tx.serialize().toString("hex");

this.web3.eth.sendSignedTransaction(raw)
web3.eth.sendSignedTransaction(raw)
.once('transactionHash', function(hash){
document.getElementById("comment").innerHTML = "Transaction sent, please wait til' it is mined"
//Arranco el spin y el boton
Expand Down Expand Up @@ -217,8 +223,8 @@
var nonce = "0x" + (nonceValue).toString(16);
rawtx = {
nonce: nonce,
gasPrice: this.web3.utils.toHex(estimatedGas),
gasLimit: this.web3.utils.toHex(GasLimit),
gasPrice: web3.utils.toHex(estimatedGas),
gasLimit: web3.utils.toHex(GasLimit),
to: contractAddress,
data: bytecodeData
};
Expand All @@ -227,15 +233,14 @@

tx.sign(privateKey);
var raw = "0x" + tx.serialize().toString("hex");
this.web3.eth.sendSignedTransaction(raw)
web3.eth.sendSignedTransaction(raw)
.once('transactionHash', function(hash){
document.getElementById("comment").innerHTML = "Transaction sent, please wait til' it is mined";
//Arranco el spin y oculto el boton
document.getElementById("spin").style.display = "block";
document.getElementById("loginButton").style.display = "none";
})
.on('error', function(error){
//console.log(error);
document.getElementById("comment").innerHTML = "";
document.getElementById("error").innerHTML = "Error in transaction";
document.getElementById("spin").style.display = "none"
Expand Down Expand Up @@ -291,6 +296,10 @@

function CompleteFields(){
var pathArray;
browser.runtime.getBackgroundPage().then((get)=>{
console.log(get.message);
document.getElementById("msg").value = get.message;
});
browser.tabs.query({active: true, currentWindow: true}).then((tabs)=>{
pathArray = tabs[0].url.split('/');
if(pathArray[2] == "twitter.com"){
Expand Down Expand Up @@ -345,7 +354,7 @@

}
}

function onError(e) {
console.error(e);
}
Expand All @@ -370,7 +379,6 @@
}

function createWeb3(){
console.log("func createweb3");
switch (selectedNetwork) {
case "Ropsten":
web3 = new Web3();
Expand All @@ -391,7 +399,7 @@
var URL = "http://localhost:7545";
web3 = new Web3(new Web3.providers.HttpProvider(URL));
Web3.providers.HttpProvider.prototype.sendAsync = Web3.providers.HttpProvider.prototype.send
contractAddress = "0xd002c4f91e4ad8650455ea5949c6cc1dd2ca0140";
contractAddress = "0x9ab56344fd3033d8339eb0b9a6723442adfab3a7";
break;
}

Expand Down
17 changes: 17 additions & 0 deletions Plugin/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var url = window.location.href;
var oldUrl;

window.setInterval(function(){
if (oldUrl != url){
oldUrl = url;
var msg = document.getElementsByClassName("TweetTextSize TweetTextSize--jumbo js-tweet-text tweet-text")[0].innerHTML;
browser.runtime.sendMessage(msg, function(response) {
console.log("Response: ", response);
});
}
url = window.location.href;
}, 250);




11 changes: 11 additions & 0 deletions Plugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
"content_security_policy": "default-src * 'unsafe-inline' 'unsafe-eval'; script-src 'self' 'unsafe-eval'; object-src 'self'; style-src 'self' 'unsafe-inline' 'unsafe-eval';",
"applications": {
"gecko": {
"id": "webextension@block.io"
}
},
"background": {
"scripts": ["background.js"]
},

"content_scripts": [{
"matches": ["*://twitter.com/*"],
"js": ["content.js"],
"all_frames": true
}],
"browser_action": {
"default_icon": {
"19": "images/icon-19.png",
Expand All @@ -25,6 +35,7 @@
"*://*/*",
"tabs",
"webRequest",
"webNavigation",
"storage",
"activeTab"
]
Expand Down
20 changes: 8 additions & 12 deletions Plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline';">
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="./web3/web3.js"></script>
<script type="text/javascript" src="./web3/ethereumjs-tx.js"></script>
Expand All @@ -23,18 +21,16 @@
<option>MainNet</option>
</select>
</form>
<script src="./block.js" type="text/javascript" charset="utf-8"></script>
<button onclick="setNetwork()" class="boton_personalizado">Set Network</button>
<input id="setNet" type="button" class="boton_personalizado" value="Set Network">

<hr size="1px">
<p class="login">
<b>Register:</b><br>
<input type="password" id="pk" required minlength="64" maxlength="64" placeholder="Enter your private key"> <br>
<input class="boton_personalizado" type="button" value="Login" onclick="Login()" style="display: block;"
id="loginButton" />
<input id="loginButton" class="boton_personalizado" type="button" value="Login" style="display: block;" />
</p>
<br>
<input class="boton_personalizado" type="button" value="AutoComplete" onclick="CompleteFields()"
style="display: block;" id="completeFields" />
<button class="boton_personalizado" type="button" value="AutoComplete" style="display: block;" id="completeFields">AutoComplete</button>
<br>
<input type="text" id="url_id" placeholder="https://"><br>
<br>
Expand All @@ -44,13 +40,13 @@
<div id="spin" class="loader" style="display: none;"></div>
<br>
<div style="width: 200px; margin: auto;">
<input class="boton_grande" style="float:left;" type="button" value="Submit&#13;&#10;message"
onclick="SubmitToBlockchain()" style="display: block;" id="submitButton" />
<input class="boton_grande" style="float:right;" type="button" value="Check&#13;&#10;integrity"
onclick="CheckIntegrity()" style="display: block;" id="checkButton" />
<input class="boton_grande" style="float:left;" type="button" value="Submit&#13;&#10;message" style="display: block;" id="submitButton" />
<input class="boton_grande" style="float:right;" type="button" value="Check&#13;&#10;integrity" style="display: block;" id="checkButton" />
</div>
<h3 id="comment"></h3>
<b id="error" style="color: red;"></b>
<script src="./block.js" type="text/javascript" charset="utf-8"></script>

</body>

</html>