Skip to content

Commit

Permalink
[Prototype] Player Blacklist for Auto-accept and Chrome option page
Browse files Browse the repository at this point in the history
Still WIP but player blacklist is functional
  • Loading branch information
Poheart committed Dec 11, 2016
1 parent 355ca5a commit 598d3a8
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 3 deletions.
67 changes: 67 additions & 0 deletions contact.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>FACEIT HELPER</title>
<!-- Bootstrap core CSS -->
<link href="../lib/tether.min.css" rel="stylesheet">
<link href="../lib/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<style>
body {
padding-top: 5rem;
background:#f5f5f5;
}
.headtitle {
padding: 10rem 1.5rem;
text-align: center;
}
.descbox {
background-color: #eceeef;
border-radius: 10px;
padding: 10%;
}
</style>
<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
<a class="navbar-brand" href="#">
<img src="icons/icon128.png" width="30" height="30" class="d-inline-block align-top rounded" alt="">
FACEIT HELPER </a>
<ul class="nav navbar-nav">
<li class="nav-item">
<a class="nav-link" href="options.html?">Main</a>
</li>
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://github.com/Poheart/FACEIT-HELPER">Github</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>

</nav>

<div class="container-fluid">
<div class="headtitle">
<h1>FACEIT HELPER</h1>
<p class="lead">Made with ♥ by Poheart<br>
<a href="http://steamcommunity.com/id/CrazyGamer2011/" class="btn btn-outline-primary">Steam </a>
<a href="https://www.poheart.net" class="btn btn-outline-warning">Web</a>
<a href="https://github.com/Poheart/FACEIT-HELPER" class="btn btn-outline-danger">Github</a>
<a href="https://chrome.google.com/webstore/detail/faceit-helper/bjdhcabjnhhifipbnopnfpfidkafanjf" class="btn btn-outline-success">Chrome Store</a>
<hr>Thanks to the following contributors in GitHub made it possible! <br>
CullenIO, nuller1joe</p>
</div>


</div>
<!-- /.container -->
<script src="../lib/jquery.min.js"></script>
<script src="../lib/tether.min.js"></script>
<script src="../lib/bootstrap.min.js"></script>
<script src="../js/option.js"></script>
</body>
</html>
33 changes: 31 additions & 2 deletions js/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var faceitHelper = {
premium: false,
matchedPlayers: false,
showStats: false,
arrayMapOrder: {}
arrayMapOrder: {},
BlackList: false
},
buttons: [
{
Expand Down Expand Up @@ -160,6 +161,7 @@ var faceitHelper = {
var joined_players = angular.element('.queue--sm').scope().quickMatch.joined_players;
$('.modal-dialog__actions').append('<hr><strong class="text-center">Players in this room</strong><ul id="player_list" class="list-unstyled"></ul>');
var userGetQueries = [];
var playerNameinQueue = [];
for (var i = 0; i < joined_players.length; i++) {
userGetQueries.push(
$.get('https://api.faceit.com/api/users/'+joined_players[i], function(e) {
Expand All @@ -172,6 +174,8 @@ var faceitHelper = {
type: e.payload.membership.type,
teamid: e.payload.active_team_id
};
// Add player name in the array for checking blacklist later
playerNameinQueue.push(e.payload.nickname);

var list = $('<li/>').addClass("text-left")
.append($('<i/>', { id: fetchedValue.guid, class: "icon-ic_state_checkmark_48px icon-md" }))
Expand All @@ -189,6 +193,27 @@ var faceitHelper = {
}
$.when.apply($, userGetQueries).done(function() {
faceitHelper.timerCheckAcceptedPlayers(faceitHelper.globalstate.user.currentState);

if(faceitHelper.userSettings.BlackList) {
// Blacklist function
var blackListArray = localStorage.BlackList.split('\n');
var blackListedPlayerCount = 0;
for(var i = 0; i < playerNameinQueue.length; i++) {
for(var j=0;j< blackListArray.length;j++ ){
if(playerNameinQueue[i] == blackListArray[j]){
blackListedPlayerCount++;
}
}
}
if(blackListedPlayerCount == 0) {
faceitHelper.acceptMatch();
faceitHelper.sendNotification("<br><strong>No blacklisted player were found in the queue</strong><hr>Accepting the match...");
} else {
faceitHelper.sendNotification('<hr><span class="label label-danger">'+ blackListedPlayerCount + ' Blacklisted player(s) is found!</span><span class="text-danger"><strong><h3>Auto-accept disengaged</h3></strong></span>');
new Audio("https://faceit.poheart.net/sounds/autojoin_cancelled.mp3").play();
}
}

});
},
createButtons: function() {
Expand Down Expand Up @@ -288,6 +313,8 @@ var faceitHelper = {
faceitHelper.userSettings.matchedPlayers = (localStorage.bMatchedPlayers == "true") ? true : false;
faceitHelper.userSettings.autoJoin = (localStorage.bAutoJoin == "true") ? true : false;
faceitHelper.userSettings.showStats = (localStorage.bShowStats == "true") ? true : false;
// Chrome extension option
faceitHelper.userSettings.BlackList = (localStorage.bBlackList == "true") ? true : false;
// Fetch user map preferences
faceitHelper.fetchMapPreference();
},
Expand Down Expand Up @@ -428,8 +455,10 @@ var faceitHelper = {
}

if(currentState == "CHECK_IN") {
if(faceitHelper.userSettings.autoAccept) {
if(faceitHelper.userSettings.autoAccept && !faceitHelper.userSettings.BlackList) {
faceitHelper.acceptMatch();
} else if (faceitHelper.userSettings.autoAccept && (faceitHelper.userSettings.BlackList && faceitHelper.userSettings.matchedPlayers)){
faceitHelper.sendNotification('<span class="text-info"><strong>Player Blacklist enabled</strong><br>Waiting for player list before accept...</span>');
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ document.addEventListener('FH_getMapsPreference', function(e) {
});
});

chrome.storage.sync.get({
blacklist_enable: false,
blacklist_textarea: ''
}, function(items) {
localStorage.bBlackList = items.blacklist_enable;
localStorage.BlackList = items.blacklist_textarea;
});

document.addEventListener('FH_copyServerIP', function(e) {
copyToClipboard(e.detail.serverIP);
});
Expand Down
38 changes: 38 additions & 0 deletions js/option.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var manifest = chrome.runtime.getManifest();
var storage = chrome.storage.sync;
$(".navbar-brand").append(manifest.version);

$("#blacklist_box").change(function() {
if(this.checked) {
$("#blacklist_textarea").prop('disabled',false);
} else {
$("#blacklist_textarea").prop('disabled',true);
}
});

function save_options() {
storage.set({
blacklist_enable: $('#blacklist_box').is(':checked'),
blacklist_textarea: $('#blacklist_textarea').val()
}, function() {
console.log("Setting saved!");
$('#settingSaved').show();
setTimeout(function () {
$('#settingSaved').hide();
}, 7500);
});
}

function restore_options() {
storage.get({
blacklist_enable: false,
blacklist_textarea: ''
}, function(item) {
$('#blacklist_box').prop('checked', item.blacklist_enable);
$('#blacklist_textarea').val(item.blacklist_textarea);
$("#blacklist_textarea").prop('disabled',!item.blacklist_enable);
document.dispatchEvent(new CustomEvent('FH_getChromeOptions'));
});
}
document.addEventListener('DOMContentLoaded', restore_options);
$("#save-options").click(save_options);
7 changes: 7 additions & 0 deletions lib/bootstrap.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions lib/bootstrap.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/tether.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/tether.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "FACEIT HELPER",
"description": "FACEIT user experience enhancement tools",
"version": "3.2.5",
"version": "3.3.0",
"author": "Poheart & CullenIO",
"page_action": {
"default_icon": {
Expand All @@ -24,6 +24,7 @@
"web_accessible_resources": [
"js/inject.js"
],
"options_page": "options.html",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
Expand Down
122 changes: 122 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>FACEIT HELPER</title>
<!-- Bootstrap core CSS -->
<link href="lib/tether.min.css" rel="stylesheet">
<link href="lib/bootstrap.min.css" rel="stylesheet">
</head>

<body>
<style>
body {
padding-top: 5rem;
background: #f5f5f5;
}

.starter-template {
padding: 3rem 1.5rem;
text-align: center;
}

.descbox {
background-color: #eceeef;
border-radius: 10px;
padding: 10%;
}
</style>
<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
<a class="navbar-brand" href="#">
<img src="icons/icon128.png" width="30" height="30" class="d-inline-block align-top rounded" alt=""> FACEIT HELPER </a>
<ul class="nav navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="options.html?">Main</a>
</li>
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://github.com/Poheart/FACEIT-HELPER">Github</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
<span class="float-xs-right">
<a class="btn btn-danger" href="#" role="button" id="save-options">Save Configuration</a>
</span>
</nav>

<div class="container-fluid">
<div class="alert alert-success" role="alert" id="settingSaved" style="display:none">
<strong>Setting saved!</strong> Refresh all active FACEIT.com pages for setting to apply.
</div>
<div class="alert alert-info" role="alert">This option page is design for advanced configuration for FACEIT HELPER
<br>
<strong>Basic features toggle ON/OFF are available in the navigation bar on FACEIT.com</strong>
</div>
<!-- Head section -->
<div class="col-md-2">
<h5>General Settings</h5>
</div>
<div class="col-md-7">
<fieldset class="form-group">
<legend>Auto-veto enable on</legend>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios1" value="option1" checked> MAPS ONLY
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios2" value="option2" disabled> SERVERS ONLY
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios3" value="option3" disabled> BOTH SERVERS + MAPS

</label>
</div>
</fieldset>
</div>
<div class="col-md-3">
<div class="container descbox">
<p> This is a placeholder option and will be implemented soon.</p>
</div>
</div>
<!-- Section seperator -->
<hr class="col-md-12">
<!-- Next section -->
<div class="col-md-2">
<h5>Blacklisted Players</h5>
</div>

<div class="col-md-7">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="blacklist_box"> Enable Blacklist
</label>
</div>
<div class="form-group">
<textarea class="form-control" rows="5" id="blacklist_textarea" placeholder="Player FACEIT username(seperate each user line by line)" disabled></textarea>
</div>
</div>
<div class="col-md-3">
<div class="container descbox">
<p> Configurate Auto-accept feature to not to accept the match whenever the player(s) in the list are on your matches</p>
<p class="text-danger"> This feature requires both <strong>Show Matched Player</strong> and <strong>Auto-Accept</strong> Enabled!</p>
</div>
</div>

</div>
<!-- /.container -->
<script src="lib/jquery.min.js"></script>
<script src="lib/tether.min.js"></script>
<script src="lib/bootstrap.min.js"></script>
<script src="js/option.js"></script>
</body>

</html>

0 comments on commit 598d3a8

Please sign in to comment.