forked from bilibili-helper/bilibili-helper-o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
executable file
·77 lines (77 loc) · 2.93 KB
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$(document).ready(function() {
var bkg_page = chrome.extension.getBackgroundPage();
document.title = chrome.i18n.getMessage('extName') + " - " + chrome.i18n.getMessage('optionPage');
$("#menu_title").text(chrome.i18n.getMessage('extName'));
$("#version").html(bkg_page.version);
$("#ad_opacity_opt").hide();
$("div[option=\"" + bkg_page.getOption("replace") + "\"].replace").addClass("on");
$("div[option=\"" + bkg_page.getOption("html5") + "\"].html5").addClass("on");
$("div[option=\"" + bkg_page.getOption("contextmenu") + "\"].contextmenu").addClass("on");
$("div[option=\"" + bkg_page.getOption("dynamic") + "\"].dynamic").addClass("on");
$("div[option=\"" + bkg_page.getOption("dlquality") + "\"].dlquality").addClass("on");
$("div[option=\"" + bkg_page.getOption("rel_search") + "\"].rel_search").addClass("on");
var adOption = bkg_page.getOption("ad");
$("div[option=\"" + adOption + "\"].ad").addClass("on");
if (adOption == "fade") $("#ad_opacity_opt").show();
$("#ad_opacity").val(bkg_page.getOption("ad_opacity"));
$('.ad').click(function() {
if ($(this).hasClass('on')) return false;
$('.ad').removeClass('on');
$(this).addClass('on');
if ($(this).attr("option") == "fade") $("#ad_opacity_opt").slideDown(300);
else $("#ad_opacity_opt").slideUp(300);
bkg_page.setOption("ad", $(this).attr("option"), true);
updatepreview();
});
$('#ad_opacity').change(function() {
bkg_page.setOption("ad_opacity", $(this).val(), true);
updatepreview();
});
$('.dynamic').click(function() {
if ($(this).hasClass('on')) return false;
$('.dynamic').removeClass('on');
$(this).addClass('on');
bkg_page.setOption("dynamic", $(this).attr("option"));
});
$('.replace').click(function() {
if ($(this).hasClass('on')) return false;
$('.replace').removeClass('on');
$(this).addClass('on');
bkg_page.setOption("replace", $(this).attr("option"));
});
$('.html5').click(function() {
if ($(this).hasClass('on')) return false;
$('.html5').removeClass('on');
$(this).addClass('on');
bkg_page.setOption("html5", $(this).attr("option"));
});
$('.contextmenu').click(function() {
if ($(this).hasClass('on')) return false;
$('.contextmenu').removeClass('on');
$(this).addClass('on');
bkg_page.setOption("contextmenu", $(this).attr("option"));
if ($(this).attr("option") == 'on') {
chrome.contextMenus.create({
title: chrome.i18n.getMessage('searchBili'),
contexts: ["selection"],
onclick: bkg_page.searchBilibili
});
} else {
chrome.contextMenus.removeAll();
}
});
$('.dlquality').click(function() {
if ($(this).hasClass('on')) return false;
$('.dlquality').removeClass('on');
$(this).addClass('on');
bkg_page.setOption("dlquality", $(this).attr("option"));
updatepreview();
});
$('.rel_search').click(function() {
if ($(this).hasClass('on')) return false;
$('.rel_search').removeClass('on');
$(this).addClass('on');
bkg_page.setOption("rel_search", $(this).attr("option"));
updatepreview();
});
});