Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nusratsharmin03 authored Aug 8, 2020
2 parents 9f1a27d + 8f9aad9 commit 3db9588
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 199 deletions.
4 changes: 2 additions & 2 deletions fb-newsfeed-filter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"content_scripts": [{
"matches": ["<all_urls>"],
"run_at": "document_idle",
"js": ["scripts/jquery.js", "scripts/covid19.js", "scripts/bootstrap.js"],
"css": ["assets/styles/covid19.css", "assets/styles/bootstrap.min.css"]
"js": ["scripts/jquery.js", "scripts/covid19.js"],
"css": ["assets/styles/covid19.css"]
}],
"description": "Check Facebook for Covid19 related Misinfo",
"manifest_version": 2,
Expand Down
54 changes: 31 additions & 23 deletions fb-newsfeed-filter/scripts/background.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// ----------------- constants ---------------------
const user_study_api = 'http://coronafactcheck.herokuapp.com/covid19/api/user_study_news'
const url = "https://coronafactcheck.herokuapp.com/covid19/api/get_blacklist";
const time_gap = 2
const FB_URL = 'https://www.facebook.com/'
const user_feedback_api = ''

var urlList = []
var pattern = ["https://www.facebook.com/lalsalu.page/posts/2769601203135709",
"https://www.facebook.com/groups/brahmanbarian2017/permalink/3068719746521623/",
"https://www.facebook.com/mh.mon.94/videos/638619193593343/",
Expand All @@ -14,25 +14,25 @@ var pattern = ["https://www.facebook.com/lalsalu.page/posts/2769601203135709",
var currenturl = ""

//post request to server
var serverData;
var xmlhttp = new XMLHttpRequest();
var url = "https://coronafactcheck.herokuapp.com/covid19/api/get_blacklist";
//collect all the blacklisted urls in this urlList
var urlList = [];
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
serverData = JSON.parse(this.responseText);
//console.log(serverData)
for (i = 0; i < serverData.length; i++) {
//console.log(serverData[i]['url'])
urlList.push(serverData[i]['url'])
};
// console.log(urlList)
//console.log(pattern)
};
};
xmlhttp.open("POST", url, false);
xmlhttp.send();
// var serverData;
// var xmlhttp = new XMLHttpRequest();

// //collect all the blacklisted urls in this urlList
// var urlList = [];
// xmlhttp.onreadystatechange = function() {
// if (this.readyState == 4 && this.status == 200) {
// serverData = JSON.parse(this.responseText);
// //console.log(serverData)
// for (i = 0; i < serverData.length; i++) {
// //console.log(serverData[i]['url'])
// urlList.push(serverData[i]['url'])
// };
// // console.log(urlList)
// //console.log(pattern)
// };
// };
// xmlhttp.open("POST", url, false);
// xmlhttp.send();

var requestedURL;
// cancel function returns an object
Expand Down Expand Up @@ -212,7 +212,6 @@ function memorySizeOf(obj) {
function fetchdata() {
$.post(user_study_api)
.done(function onSuccess(result) {
console.log(result)
chrome.storage.local.set({
'CORONAMISINFO': result
}, function() {
Expand All @@ -222,8 +221,17 @@ function fetchdata() {
.fail(function onError(xhr, status, error) {
console.log(error)
})
}
// get blacklist
$.post(url).done(function onSuccess(result) {
console.log("result get blacklist",result);
for (i = 0; i < result.length; i++) {
urlList.push(result[i]['url'])
};

}).fail( function onError(xhr, status, error){
console.log(error)
})
}

console.log("browser started, fetching data");
fetchdata();
4 changes: 2 additions & 2 deletions fb-newsfeed-filter/scripts/covid19.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ $(document).ready(function() {

var infoElement = _getmisinfoInfoElement(misinfo_result.data, misinfo_popupid, postData, fbpost_id);


var closeButton = $("<div class='misinfo-marker-info-close-btn'>x</div>");

infoElement.append(closeButton);

closeButton.click(function(e) {
Expand Down Expand Up @@ -563,4 +563,4 @@ $(document).ready(function() {
loop();
}
})();
});
});
155 changes: 0 additions & 155 deletions privacy-policy.html

This file was deleted.

19 changes: 8 additions & 11 deletions server-for-extension/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,16 @@ def fetching_user_news():
news_list = db_operation.fetch_all('user_study')
return json.dumps(news_list)

@app.route('/user_feedback', methods=['POST'])
@app.route('/covid19/api/user_feedback', methods=['POST'])
def receive_user_feedback():
feedback = request.values.get('feedback')
print(feedback)
feedback = request.values.get('data')
feedback = json.loads(feedback)
user = feedback['uuid']
verdict ="vote_down" if feedback['verdict']==0 else "vote_up"
item_id = feedback['item_id']
print(user, verdict, item_id)
db_operation.write_feedback(item_id, user, verdict)
user = feedback['uid']
action = feedback['action']
post_id = feedback['post_id']
time = feedback['time']
db_operation.write_feedback(user,action,post_id, time)
return 'Sucesss'



if __name__ == '__main__':
app.run(host = '0.0.0.0',port=5005, debug=True)
app.run(ssl_context='adhoc', debug=True)
Loading

0 comments on commit 3db9588

Please sign in to comment.