Skip to content

Instantly share code, notes, and snippets.

@bluelovers
Last active August 29, 2015 14:21
Show Gist options
  • Save bluelovers/3ea67f4344c17ec82e65 to your computer and use it in GitHub Desktop.
Save bluelovers/3ea67f4344c17ec82e65 to your computer and use it in GitHub Desktop.
SocialTweak_SC.user.js
// ==UserScript==
// @name SocialTweak SC
// @namespace bluelovers
// @author bluelovers
//
// @downloadURL https://gist.github.com/bluelovers/3ea67f4344c17ec82e65/raw/SocialTweak_SC.user.js
// @updateURL https://gist.github.com/bluelovers/3ea67f4344c17ec82e65/raw/SocialTweak_SC.user.js
//
// @include *
// @include https://www.facebook.com/*
// @include https://m.facebook.com/*
// @include http://www.facebook.com/*
// @include http://m.facebook.com/*
// @include http://www.buzzhand.com/post_*.html
//
// @version 1
// @grant none
// run-at document-start
//
// @require http://code.jquery.com/jquery-latest.js?KU201
// @require https://github.com/bluelovers/UserScript-Framework/raw/develop/UserScript_Framework.user.js?KU201
//
// ==/UserScript==
(function($, undefined){
var UF = Sandbox.UF;
var unsafeWindow = unsafeWindow || window;
var _url = window.location.href;
var _url_obj = _url_obj_ = parse_url(_url);
var _url_host = _url_obj.host;
console.log([456, Sandbox]);
if (0)
{
//
}
else if (_url_host.match(/buzzhand\.com/))
{
UF.addStyle([
'#container > .article_wrap { -moz-user-select: auto !important; -webkit-user-select: auto !important; -ms-user-select: auto !important; }',
'html, body { font-size: 10pt; }',
'html, body { font-family: Consolas,"Liberation Mono",Menlo,Courier,monospace; }',
'.f18 { font-size: 1rem; }',
]);
_uf_disable_nocontextmenu(1, '#container > .article_wrap');
}
else
{
//
}
function _uf_disable_nocontextmenu(mode, elem)
{
var _jquery_array = [$];
var _unsafeJquery;
var _jquery;
if (mode > 1)
{
var _style = $('style#_uf_disable_nocontextmenu');
if (!_style.size())
{
_style = UF.addStyle('* { -moz-user-select: auto !important; -webkit-user-select: auto !important; -ms-user-select: auto !important; }');
$(_style).attr('id', '_uf_disable_nocontextmenu');
}
if (unsafeWindow.$ && unsafeWindow.$.fn && unsafeWindow.$.fn.jquery)
{
_unsafeJquery = unsafeWindow.$;
_jquery_array[_jquery_array.length] = _unsafeJquery;
}
}
var _fn_jq_call = function(_jquery, arr, fn, event){
if (_jquery.fn[fn])
{
$.each(event, function(i, v){
arr[fn](v);
});
}
};
// _jquery = _jquery_array[0];
var _fn_event = ['dragstart', 'contextmenu', 'selectstart', 'mousedown', 'mouseup', 'source'];
$.each(_jquery_array, function(key, _jquery){
var arr = _jquery(unsafeWindow.document).add('body, html');
if (elem)
{
arr = arr.add(elem);
}
// _uf_log('_uf_disable_nocontextmenu', mode, elem, _jquery_array, _jquery, _jquery.fn.jquery, arr);
arr
.removeAttr('ondragstart')
.removeAttr('oncontextmenu')
.removeAttr('onselectstart')
.removeAttr('onmousedown')
.removeAttr('onmouseup')
.removeAttr('onsource')
.css({
'-moz-user-select': 'auto',
'-webkit-user-select': 'auto',
'-ms-user-select': 'auto',
'user-select': 'auto',
})
;
if (mode)
{
arr
.each(function(){
this.oncontextmenu = this.ondragstart = this.onselectstart = this.onmousedown = this.onmouseup = this.onsource = null;
})
;
if (_jquery.fn.off)
{
/*
arr
.off('dragstart')
.off('contextmenu')
.off('selectstart')
.off('mousedown')
.off('mouseup')
.off('source')
;
*/
_fn_jq_call(_jquery, arr, 'off', _fn_event);
}
else
{
/*
if (_jquery.fn.unbind)
{
arr
.unbind('dragstart')
.unbind('contextmenu')
.unbind('selectstart')
.unbind('mousedown')
.unbind('mouseup')
.unbind('source')
;
}
if (_jquery.fn.die)
{
arr
.die('dragstart')
.die('contextmenu')
.die('selectstart')
.die('mousedown')
.die('mouseup')
.die('source')
;
}
*/
_fn_jq_call(_jquery, arr, 'unbind', _fn_event);
_fn_jq_call(_jquery, arr, 'die', _fn_event);
}
}
});
}
})();
function parse_url(str, component)
{
// http://kevin.vanzonneveld.net
// + original by: Steven Levithan (http://blog.stevenlevithan.com)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + input by: Lorenzo Pisani
// + input by: Tony
// + improved by: Brett Zamir (http://brett-zamir.me)
// % note: Based on http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// % note: blog post at http://blog.stevenlevithan.com/archives/parseuri
// % note: demo at http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// % note: Does not replace invalid characters with '_' as in PHP, nor does it return false with
// % note: a seriously malformed URL.
// % note: Besides function name, is essentially the same as parseUri as well as our allowing
// % note: an extra slash after the scheme/protocol (to allow file:/// as in PHP)
// * example 1: parse_url('http://username:password@hostname/path?arg=value#anchor');
// * returns 1: {scheme: 'http', host: 'hostname', user: 'username', pass: 'password', path: '/path', query: 'arg=value', fragment: 'anchor'}
var key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
'relative', 'path', 'directory', 'file', 'query', 'fragment'],
ini = (this.php_js && this.php_js.ini) || {},
mode = (ini['phpjs.parse_url.mode'] && ini['phpjs.parse_url.mode'].local_value) || 'php',
parser = {
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
};
var m = parser[mode].exec(str),
uri = {},
i = 14;
while (i--)
{
if (m[i])
{
uri[key[i]] = m[i];
}
}
if (component)
{
return uri[component.replace('PHP_URL_', '').toLowerCase()];
}
if (mode !== 'php')
{
var name = (ini['phpjs.parse_url.queryKey'] && ini['phpjs.parse_url.queryKey'].local_value) || 'queryKey';
parser = /(?:^|&)([^&=]*)=?([^&]*)/g;
uri[name] = {};
uri[key[12]].replace(parser, function($0, $1, $2)
{
if ($1)
{
uri[name][$1] = $2;
}
});
}
for (i in key)
{
if (!uri[key[i]])
{
uri[key[i]] = '';
}
}
delete uri.source;
return uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment