Skip to content

Commit

Permalink
add vidangel support
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu2013 committed Nov 23, 2016
1 parent 9b0ebc5 commit 1bae138
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 37 deletions.
10 changes: 6 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"manifest_version": 4,

"name": "Bad-Movie-No-More (Redbox movie ratings)",
"name": "Bad-Movie-No-More (Redbox/Vidangel movie ratings)",
"author": "Sky Liu",
"description": "Attach imdb and rotten tomatoes ratings to the movies listed in Redbox",
"short_name": "Redbox Movie Ratings",
"description": "Attach imdb and rotten tomatoes ratings to the movies listed in Redbox/VidAngel",
"short_name": "Redbox/VidAngel Movie Ratings",
"icons": {
"128": "images/redbox.png"
},
Expand All @@ -21,14 +21,16 @@
{
"all_frames": true,
"matches": [
"*://www.redbox.com/*"
"*://www.redbox.com/*",
"*://www.vidangel.com/*"
],
"js": ["scripts/jquery-1.11.2.min.js", "scripts/imagesloaded.pkgd.js", "scripts/redbox_rating.js"],
"css": ["styles/label.css"]
}
],
"permissions": [
"https://www.redbox.com/*",
"https://www.vidangel.com/*",
"storage",
"tabs"
],
Expand Down
2 changes: 1 addition & 1 deletion scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ chrome.pageAction.onClicked.addListener(function(tab) {
// Called when the url of a tab changes.
function checkForValidUrl(tabId, changeInfo, tab) {
// If the tabs url contains 'redbox.com'...
if (tab.url.indexOf('redbox.com') > -1) {
if ((tab.url.indexOf('redbox.com') > -1) || (tab.url.indexOf('vidangel.com') > -1)){
// ... show the page action.
chrome.pageAction.show(tabId);
}
Expand Down
79 changes: 47 additions & 32 deletions scripts/redbox_rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,38 +203,48 @@ function getAllRatings() {

// For vidangel.com
if(url.indexOf('vidangel.com') > -1) {
console.log("it's vidangel.com");
//// For vidangel home page
//$('div.overlay__title.ng-binding').each(function(index){
// var movieTitle = this.textContent.indexOf("(") > -1 ? this.textContent.split("(")[0] : this.textContent;
//
// var movieYear = null;
// if (this.textContent.indexOf("(") > -1) {
// if (!isNaN(this.textContent.split("(")[1].split(")")[0])) {
// movieYear = this.textContent.split("(")[1].split(")")[0];
// }
// }
//
// var $div = $("<div>", {id: "rr" + index});
// $(this).before($div);
//
// console.log(movieTitle);
//
// getRating(movieTitle, movieYear, ("rr" + index), $(this).parents('.hero-box').length, $(this).parents("[style='width: 228px;']").length);
//});

//// For vidangel detail page
//$('div.title__title.ng-binding').each(function(index){
// var movieTitle = this.textContent;
// var movieYear = null;
//
// var $div = $("<div>", {id: "rr" + index});
// $(this).before($div);
//
// console.log(movieTitle);
//
// getRating(movieTitle, movieYear, ("rr" + index), $(this).parents('.hero-box').length, $(this).parents("[style='width: 228px;']").length);
//});

var global_index = 0;

// For vidangel home page
$('a.poster__label.ng-binding').each(function(index){
if($(this).prev('div[id^=rr]').length == 0) {
var movieTitle = this.textContent.indexOf("(") > -1 ? this.textContent.split("(")[0] : this.textContent;

var movieYear = null;
if (this.textContent.indexOf("(") > -1) {
if (!isNaN(this.textContent.split("(")[1].split(")")[0])) {
movieYear = this.textContent.split("(")[1].split(")")[0];
}
}

var $div = $("<div>", {id: "rr" + index});
$(this).prev().append($div);

getRating(movieTitle, movieYear, ("rr" + index), $(this).parents('.hero-box').length, $(this).parents("[style='width: 228px;']").length);

global_index = index;
}
});

// For vidangel detail page
$('div.title__title.ng-binding').each(function(index){
if($(this).prev('div[id^=rr]').length == 0) {
var movieTitle = this.textContent;

var movieYear = null;
if (this.textContent.indexOf("(") > -1) {
if (!isNaN(this.textContent.split("(")[1].split(")")[0])) {
movieYear = this.textContent.split("(")[1].split(")")[0];
}
}

var $div = $("<div>", {id: "rr" + (index+global_index)});
$(this).parent().parent().parent().parent().prev().append($div);

getRating(movieTitle, movieYear, ("rr" + (index+global_index)), $(this).parents('.hero-box').length, $(this).parents("[style='width: 228px;']").length);
}
});
}
}

Expand All @@ -254,7 +264,12 @@ chrome.runtime.onMessage.addListener(

///////// INIT /////////////
$(window).load(function(){getAllRatings();});
////////////////////////////




///// ***** Try to tackle infinite-scrolling issue, but no luck with the following approach ***** /////
//$('img').load(function(){
// console.log("hello");
//getAllRatings();});
Expand Down

0 comments on commit 1bae138

Please sign in to comment.