代码拉取完成,页面将自动刷新
同步操作将从 自来水煮鱼/wayixia-chrome-extension 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*!
* wayixia chrome plugin config api
*/
function user_config_is_new() {
var current_version = user_config_get('wayixia_version');
console.log(current_version + ' -> ' + chrome.runtime.getManifest().version);
var result = (parseFloat(current_version, 10) < parseFloat(chrome.runtime.getManifest().version, 10));
//user_config_set('wayixia_version', chrome.runtime.getManifest().version);
return result;
}
function user_config_version_ok() {
user_config_set('wayixia_version', chrome.runtime.getManifest().version);
}
function user_config_load(data) {
var config = JSON.parse(data);
if(config) {
for(var name in config) {
localStorage.setItem(name, config[name]);
}
}
}
function user_config_tostring() {
var config_names = ['save_path', 'date_folder', 'view_type'];
var config = {};
for(var i=0; i<config_names.length; i++) {
var name = config_names[i];
config[name] = user_config_get(name);
}
console.log(JSON.stringify(config));
}
function user_config_set(key, value) {
localStorage.setItem(key, value);
}
function user_config_get(key) {
return localStorage.getItem(key);
}
/*!
* add block image
*/
function block_image_add(url) {
var images = JSON.parse(localStorage.getItem('block_images')) || {};
images[url] = 1;
localStorage.setItem('block_images', JSON.stringify(images));
}
/*!
* remove block image
*/
function block_image_remove(url) {
var images = JSON.parse(localStorage.getItem('block_images')) || {};
delete images[url];
localStorage.setItem('block_images', JSON.stringify(images));
}
/*!
* check image is blocked
* @param url {string} - image url
*/
function is_block_image(url) {
var images = JSON.parse(localStorage.getItem('block_images')) || {};
return !!images[url];
}
/*!
* get all block images
*/
function block_images_all() {
return JSON.parse(localStorage.getItem('block_images')) || {};
}
/*!
* set view type of image box
* @param t - view type, enum: size_1, size_2, size_3
*/
function view_type_set(t) {
user_config_set('view_type', t);
}
/*!
* get current view type of image box
*/
function view_type() {
var type = user_config_get('view_type');
if( type == "size_1"
|| type == "size_2"
|| type == "size_3")
{
return type;;
}
return "size_2";
}
/*!
* filter rules api
*/
/*!
* set/get version of filter rules
*/
function filter_rule_version() {
if(arguments.length > 0) {
var v = parseInt(arguments[0], 10);
if(!isNaN(v)) {
user_config_set('filter_rule_version', v);
}
} else {
return user_config_get('filter_rule_version');
}
}
/*!
* enable/disable filter rule
* @param b {bool} - enable or disable filter rule
*/
function filter_rule_enable(b) {
user_config_set('filter_rule_enable', b?1:0);
}
/*!
* filter rule is enabled
*/
function filter_rule_is_enabled() {
var enabled = user_config_get('filter_rule_enable');
return (parseInt(enabled, 10) != 0);
}
/*!
* get all filter rules
*/
function filter_rule_get() {
var rules_config = JSON.parse(user_config_get('filter_rules'));
if(rules_config && (typeof rules_config == "object")) {
} else {
rules_config = {version: 0, rules: {}};
}
if(rules_config.version === undefined || isNaN(rules_config.version))
rules_config.version = 0;
if(rules_config.rules === undefined)
rules_config.rules = {};
return rules_config;
}
/*!
* set filter rules
* @param {Array} - rule list
*/
function filter_rule_set(rules) {
var rules_config = filter_rule_get();
for(var name in rules) {
rules_config.rules[name] = rules[name];
}
user_config_set('filter_rules', JSON.stringify(rules_config));
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。