-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8f7e647
Showing
9 changed files
with
926 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/web-ext-artifacts | ||
/build |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# About | ||
|
||
**KPFB** - browser extension that adds a button to any [kinopoisk](https://www.kinopoisk.ru) film page. When the button was clicked it will open [flicksbar's](https://www.flicksbar.mom/) page for corresponding film. | ||
|
||
![](images/KPFB.png) | ||
|
||
# Deprecated versions | ||
|
||
- [KPFB for firefox](https://github.com/Clovis1444/KPFB-firefox) | ||
- [KPFB for chrome](https://github.com/Clovis1444/KPFB-chrome) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "KPFB", | ||
"version": "0.0.4", | ||
"description": "Quick redirrect to Flickbar from Kinopoisk.", | ||
"browser_specific_settings": { | ||
"gecko": { | ||
"id": "KPFB@CLVS" | ||
} | ||
}, | ||
"icons": { | ||
"48": "icons/kpfb-48.png" | ||
}, | ||
"permissions": [ | ||
"tabs" | ||
], | ||
"background": { | ||
"scripts": [ | ||
"src/openFb.js" | ||
] | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": [ | ||
"*://*.kinopoisk.ru/film/*", | ||
"*://*.kinopoisk.ru/series/*" | ||
], | ||
"js": [ | ||
"src/kpfb.js" | ||
] | ||
} | ||
], | ||
"web_accessible_resources": [ | ||
"icons/kpfb-48.png" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
if (typeof browser === "undefined") { | ||
var browser = chrome; | ||
} | ||
|
||
class Kpfb { | ||
static #FB_URL = "https://flicksbar.mom"; | ||
static #PARENT1() { | ||
return document.querySelector( | ||
"html > body > div > div > div:nth-of-type(2) > main > div > div:nth-of-type(2) > div > div:nth-of-type(3) > div > div > div > div > div > div:nth-of-type(2) > div:nth-of-type(2) > div" | ||
); | ||
} | ||
static #PARENT2() { | ||
return document.querySelector( | ||
"html > body > div > div > div:nth-of-type(2) > main > div > div:nth-of-type(2) > div > div:nth-of-type(3) > div > div > div > div > div > div:nth-of-type(2) > div" | ||
); | ||
} | ||
static #PARENT3() { | ||
return document.querySelector( | ||
"html > body > div > div > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) > div > div:nth-of-type(3) > div > div > div > div > div > div:nth-of-type(2) > div" | ||
); | ||
} | ||
|
||
static #BUTTON_ONCLICK() { | ||
try { | ||
const kpUrl = window.location.href; | ||
|
||
browser.runtime.sendMessage({ | ||
command: "openFb", | ||
url: Kpfb.getFbLink(kpUrl), | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
|
||
static #getFilmId(url) { | ||
let film = url.pathname.toString(); | ||
|
||
if (!film) { | ||
throw "Error(KPFB): Failed to find film id"; | ||
} | ||
|
||
return film; | ||
} | ||
|
||
static #createFbLink(film) { | ||
return this.#FB_URL + film; | ||
} | ||
|
||
// Must handle exceptions when calling this methode | ||
static getFbLink(kpUrl) { | ||
try { | ||
kpUrl = new URL(kpUrl); | ||
const film = this.#getFilmId(kpUrl); | ||
|
||
return this.#createFbLink(film); | ||
} catch (e) { | ||
throw e; | ||
} | ||
} | ||
|
||
static createButton() { | ||
// Button | ||
const kpfb_button = document.createElement("img"); | ||
kpfb_button.id = "KPFB"; | ||
kpfb_button.style.width = "48px"; | ||
kpfb_button.style.height = "48px"; | ||
kpfb_button.style.paddingRight = "10px"; | ||
kpfb_button.title = "Watch on Flicksbar"; | ||
|
||
const img = browser.runtime.getURL("icons/kpfb-48.png"); | ||
kpfb_button.src = img; | ||
|
||
kpfb_button.onclick = this.#BUTTON_ONCLICK; | ||
|
||
const parent = this.#PARENT1() ?? this.#PARENT2() ?? this.#PARENT3(); | ||
parent.appendChild(kpfb_button); | ||
} | ||
} | ||
|
||
function main() { | ||
Kpfb.createButton(); | ||
} | ||
|
||
// Call main() | ||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
if (typeof browser === "undefined") { | ||
var browser = chrome; | ||
} | ||
|
||
function openNewTab(url, index) { | ||
browser.tabs.create({ | ||
url: url, | ||
index: index, | ||
}); | ||
} | ||
|
||
function main() { | ||
browser.runtime.onMessage.addListener((message) => { | ||
if (message.command === "openFb") { | ||
browser.tabs.query( | ||
{ active: true, lastFocusedWindow: true }, | ||
(tabs) => { | ||
openNewTab(message.url, tabs[0].index + 1); | ||
// use `url` here inside the callback because it's asynchronous! | ||
} | ||
); | ||
} | ||
}); | ||
} | ||
|
||
// Call main() | ||
main(); |