Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pjax page update support #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web-ext-artifacts/
38 changes: 22 additions & 16 deletions assets/js/follow-me-or-not.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
/*
* @Author: prabhakar
* @Date: 2016-08-14 02:20:23
* @Last Modified by: Prabhakar Gupta
* @Last Modified time: 2016-09-17 11:53:32
* @Last Modified by: Kuba Niewiarowski
* @Last Modified time: 2017-07-15 19:35:32
*/

$(document).ready(function(){
var username_a = $('meta[name=user-login]').attr("content").trim();
var username_b = $("meta[property='profile:username']").attr("content").trim();
var url = "https://api.github.com/users/" + username_b + "/following/" + username_a;
var new_text = username_b + "<br><span class='text-muted text-small'>FOLLOWS YOU</span>";
$(function(){
function process() {
var username_a = $('meta[name=user-login]').attr("content").trim();
var username_b = $("meta[property='profile:username']").attr("content").trim();
var url = "https://api.github.com/users/" + username_b + "/following/" + username_a;
var new_text = username_b + "<br><span class='text-muted text-small'>FOLLOWS YOU</span>";

// if "username_a" is empty, user is not logged in
// is "username_b" is empty, it is not user page
if(username_a != "" && username_b != "" && username_a != username_b){
$.ajax({
url : url,
success : function(data){
$("span.vcard-username").html(new_text);
},
});
// if "username_a" is empty, user is not logged in
// is "username_b" is empty, it is not user page
if(username_a != "" && username_b != "" && username_a != username_b){
$.ajax({
url : url,
success : function(data){
$("span.vcard-username").html(new_text);
},
});
}
}

process();

$(document).on('pjax:success', process);
});
20 changes: 7 additions & 13 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,22 @@
"name": "Follow Me or Not",
"description": "Check if the GitHub profile you are visiting, follows you or not in a Twitter-like UI",
"short_name": "Follow Me or Not",
"version": "1.0.0.1",
"version": "1.0.0.2",
"author": "Prabhakar Gupta",
"homepage_url": "https://github.com/mkstn/follow-me-or-not",

"browser_action": {
"default_title": "Follow Me or Not",
"default_icon": "assets/images/icon.png"
},

"icons": {
"16": "assets/images/icon.png",
"48": "assets/images/icon.png",
"128": "assets/images/icon.png"
"256": "assets/images/icon.png"
},

"permissions": ["activeTab"],

"permissions": [
"*://api.github.com/*"
],

"content_scripts": [
{
"matches": [
"https://github.com/*",
"http://github.com/*"
"*://github.com/*"
],
"js": [
"assets/js/jquery.min.js",
Expand Down