Skip to content

Commit

Permalink
added CSFD link and rating to sub details
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Richter committed Aug 21, 2014
1 parent cb1484b commit 7215997
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
7 changes: 7 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- v pozadavcich ciselne hodnoceni z CSFD a IMDB misto textu, klikaci odkazy na dane weby
- u CSFD hodnoceni barevne odlisit pozadi (modre/cervene 70%+)
- pridat hodnoceni a odkazy do vypisu konkretniho filmu
- vypsat existenci (ano/ne) anglickych titulek k filmu z subtitleseekr api?

*IMDB api http://www.omdbapi.com/
*CSFD api http://csfdapi.cz/
42 changes: 42 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
function searchMovie (title,year) {
$.get("http://csfdapi.cz/movie?search="+title,function(data) {
var id = false;
for (var resultsCount = data.length,i=0; i < resultsCount; i++) {
if (year == data[i]["year"]) {
id = data[i]["id"];
break;
}
}

if (id) {
$.get("http://csfdapi.cz/movie/"+id,function(data) {
makeMagic(data["rating"],data["csfd_url"]);
});
}

});
}

function makeMagic (rating,url) {
console.log(rating,url);
$("a[target='imdb']").after("<a href=\""+url+"\" target=\"csfd\"><img src=\"chrome-extension://"+chrome.runtime.id+"/csfd.png\" alt=\"CSFD.cz\"></a>");
if (typeof rating !== "undefined") {
var ratingBg = "plus-rating-blue";
if (rating >= 70) ratingBg = "plus-rating-red";
if (rating <= 30) ratingBg = "plus-rating-black";
$("#contcont").prepend("<div title =\"hodnocení na CSFD\" class =\"plus-rating "+ratingBg+"\"><a href=\""+url+"\" target=\"csfd\">"+rating+"%</a></div>");
}
else {
$("#contcont").prepend("<div title =\"hodnocení na CSFD - prozatím nelze hodnotit\" class =\"plus-rating\"><a href=\""+url+"\" target=\"csfd\"><img src =\"chrome-extension://"+chrome.runtime.id+"/lock.png\"></a></div>");
}
}

$(document).ready(function() {
$("a[href$='Logoff=true']").closest("table").after("<a href =\"http://www.titulky.com/index.php?Preklad=0\" class =\"plus-new\">Nový překlad</a>");
if (location.href.indexOf("Stat=6") !== -1)
Expand All @@ -15,4 +48,13 @@ $(document).ready(function() {
$(value).after("<td><a title =\"vyhledat film na ČSFD\" target =\"_blank\" href =\"http://www.csfd.cz/hledat/?q="+title[0]+"\">CSFD</a></td>");
});
}

if ($("h1").length && $("a[target='imdb']").length)
{
var titleArray = $("h1").text().split(" ("),
title = titleArray[0],
spaceTitle = title.replace(new RegExp(" ", 'g'), "+"),
year = titleArray[1].substring(0,4);
searchMovie(spaceTitle,year);
}
});
Binary file added csfd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 30 additions & 1 deletion cstyle.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#side1cont {
#side1cont, #contcont {
position: relative;
}

Expand All @@ -16,4 +16,33 @@
.plus-new:hover {
text-decoration: none;
background: #DDDDDD;
}

.plus-rating {
position: absolute;
right: 22px;
top: 75px;
color: #FFF;
background: #346792;
padding: 10px;
font-size: 2em;
font-weight: bold;
border-radius: 4px;
}

.plus-rating a, .plus-rating a:hover,.plus-rating a:visited {
text-decoration: none;
color: #FFF !important;
}

.plus-rating-blue {
background: #658DB4;
}

.plus-rating-red {
background: #BB0011;
}

.plus-rating-black {
background: #535353;
}
Binary file added lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png" },
"128": "icon128.png"
},
"permissions": ["http://csfdapi.cz/"],
"web_accessible_resources": [
"*.png"
],
"content_scripts": [
{
"matches": ["http://www.titulky.com/*"],
Expand Down

0 comments on commit 7215997

Please sign in to comment.