x-browser compat, persistent autohide state
This commit is contained in:
parent
254b62e72a
commit
93721c11ba
@ -63,6 +63,31 @@ mouseup: ->
|
|||||||
window.removeEventListener('mousemove', mousemove, true)
|
window.removeEventListener('mousemove', mousemove, true)
|
||||||
window.removeEventListener('mouseup', mouseup, true)
|
window.removeEventListener('mouseup', mouseup, true)
|
||||||
|
|
||||||
|
#x-browser
|
||||||
|
if typeof GM_deleteValue == 'undefined'
|
||||||
|
this.GM_setValue: (name, value) ->
|
||||||
|
value: (typeof value)[0] + value
|
||||||
|
localStorage.setItem(name, value)
|
||||||
|
|
||||||
|
this.GM_getValue: (name, defaultValue) ->
|
||||||
|
if not value: localStorage.getItem(name)
|
||||||
|
return defaultValue
|
||||||
|
type: value[0]
|
||||||
|
value: value.substring(1)
|
||||||
|
switch type
|
||||||
|
when 'b'
|
||||||
|
return value == 'true'
|
||||||
|
when 'n'
|
||||||
|
return Number(value)
|
||||||
|
else
|
||||||
|
return value
|
||||||
|
|
||||||
|
this.GM_addStyle: (css) ->
|
||||||
|
style: tag('style')
|
||||||
|
style.type: 'text/css'
|
||||||
|
style.textContent: css
|
||||||
|
$('head', document).appendChild(style)
|
||||||
|
|
||||||
|
|
||||||
GM_addStyle('
|
GM_addStyle('
|
||||||
#filter {
|
#filter {
|
||||||
@ -159,11 +184,12 @@ autoHideF: ->
|
|||||||
filter.className: 'reply autohide'
|
filter.className: 'reply autohide'
|
||||||
else
|
else
|
||||||
filter.className: 'reply'
|
filter.className: 'reply'
|
||||||
|
GM_setValue('className', filter.className)
|
||||||
|
|
||||||
|
|
||||||
filter: tag('div')
|
filter: tag('div')
|
||||||
filter.id: 'filter'
|
filter.id: 'filter'
|
||||||
autoHideF()
|
filter.className: GM_getValue('className', 'reply')
|
||||||
position(filter)
|
position(filter)
|
||||||
|
|
||||||
bar: tag('div')
|
bar: tag('div')
|
||||||
|
|||||||
@ -87,6 +87,35 @@
|
|||||||
window.removeEventListener('mousemove', mousemove, true);
|
window.removeEventListener('mousemove', mousemove, true);
|
||||||
return window.removeEventListener('mouseup', mouseup, true);
|
return window.removeEventListener('mouseup', mouseup, true);
|
||||||
};
|
};
|
||||||
|
//x-browser
|
||||||
|
if (typeof GM_deleteValue === 'undefined') {
|
||||||
|
this.GM_setValue = function GM_setValue(name, value) {
|
||||||
|
value = (typeof value)[0] + value;
|
||||||
|
return localStorage.setItem(name, value);
|
||||||
|
};
|
||||||
|
this.GM_getValue = function GM_getValue(name, defaultValue) {
|
||||||
|
var type, value;
|
||||||
|
if (!(value = localStorage.getItem(name))) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
type = value[0];
|
||||||
|
value = value.substring(1);
|
||||||
|
if (type === 'b') {
|
||||||
|
return value === 'true';
|
||||||
|
} else if (type === 'n') {
|
||||||
|
return Number(value);
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.GM_addStyle = function GM_addStyle(css) {
|
||||||
|
var style;
|
||||||
|
style = tag('style');
|
||||||
|
style.type = 'text/css';
|
||||||
|
style.textContent = css;
|
||||||
|
return $('head', document).appendChild(style);
|
||||||
|
};
|
||||||
|
}
|
||||||
GM_addStyle(' \
|
GM_addStyle(' \
|
||||||
#filter { \
|
#filter { \
|
||||||
position: fixed; \
|
position: fixed; \
|
||||||
@ -186,17 +215,12 @@ display: none; \
|
|||||||
return _a;
|
return _a;
|
||||||
};
|
};
|
||||||
autoHideF = function autoHideF() {
|
autoHideF = function autoHideF() {
|
||||||
if (filter.className === 'reply') {
|
filter.className === 'reply' ? (filter.className = 'reply autohide') : (filter.className = 'reply');
|
||||||
filter.className = 'reply autohide';
|
return GM_setValue('className', filter.className);
|
||||||
return filter.className;
|
|
||||||
} else {
|
|
||||||
filter.className = 'reply';
|
|
||||||
return filter.className;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
filter = tag('div');
|
filter = tag('div');
|
||||||
filter.id = 'filter';
|
filter.id = 'filter';
|
||||||
autoHideF();
|
filter.className = GM_getValue('className', 'reply');
|
||||||
position(filter);
|
position(filter);
|
||||||
bar = tag('div');
|
bar = tag('div');
|
||||||
bar.textContent = '4chon foltor';
|
bar.textContent = '4chon foltor';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user