enter something useful
Version vom
Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greatest.deepsurf.us/scripts/9160/45900/My%20Function%20library.js
//// ==UserScript==
// @name My Function library
// @namespace http://use.i.E.your.homepage/
// @version 0.25
// @description enter something useful
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @run-at document-start
// @created 2015-04-06
// @released 2014-00-00
// @updated 2014-00-00
// @history @version 0.25 - first version: public@released - 2015-04-12
// @compatible Greasemonkey, Tampermonkey
// @license GNU GPL v3 (http://www.gnu.org/copyleft/gpl.html)
// @copyright 2014+, Magnus Fohlström
// ==/UserScript==
/*global $, jQuery*/
/*jshint -W014, -W030, -W082*/
// -W014, laxbreak, Bad line breaking before '+'
// -W030, Expected assignment or funtion call insted saw an expression
// -W082, a function declaration inside a block statement
$.fn.waitUntilExists = function (handler, shouldRunHandlerOnce, isChild){
var found = 'found',
$this = $(this.selector),
$elements = $this.not(function () { return $(this).data(found); }).each(handler).data(found, true);
if( !isChild )
{
(window.waitUntilExists_Intervals = window.waitUntilExists_Intervals || {})[this.selector] =
window.setInterval(function () {
$this.waitUntilExists(
handler, shouldRunHandlerOnce, true);
}, 500);
}
else if (shouldRunHandlerOnce && $elements.length)
{
window.clearInterval(window.waitUntilExists_Intervals[this.selector]);
}
return $this;
};
$.fn.toggleClasses = function (add, remove, ifnone){
var $this = $( this.selector );
ifnone !== undefined && !$this.hasClass( add ) && !$this.hasClass( remove ) && $this.addClass( ifnone );
$this.addClass( add ).removeClass( remove );
};
//ScrollZoomTune("div.thumb .title a",1,-25,1,'slow');
function ScrollZoomTune(selection, zomms, tune, ani, speed)
{
var body = $('body'), sel = $( selection), position;
sel.size() !== 0 && (
body.css('zoom',zomms),
position = sel.position(),
position = position.top + tune,
ani == 1 ?
body.animate({ scrollTop: position * zomms }, speed ) :
body.scrollTop( position * zomms )
)
}
function inURL(search){
var winLoc = window.location.href;
return winLoc.search(search) !== -1;
}
function checkDividedIsInteger( num, div ){
return ( num % div === 0 );
}
function isEven(value) {
return ( value % 2 === 0 );
}
String.prototype.inURL = function(){
var winLoc = window.location.href;
return winLoc.search(this) !== -1;
};
String.prototype.inString = function(string){
return string !== undefined ? string.search(this) !== -1 : false;
};
String.prototype.inElem = function(search){
return this !== undefined ? this.search(search) !== -1 : false;
};
String.prototype.undef = function(replace){
return this === undefined ? replace : this;
};
String.prototype.extract = function( startChar, endChar, inside)
{
var str = this,
startCharIndex = str.indexOf( startChar ),
endCharIndex = str.indexOf( endChar );
str = str.substr( startCharIndex, endCharIndex);
if( inside == 'yes' || inside == 1 || inside === true || inside == 'inside')
{
str = str.replace( startChar, '').replace( endChar, '');
}
return str;
};
/**
* @return {string}
*/
function Undefined(check,replace){
return check === undefined ? replace.toString() : check.toString();
}
$.fn.extend({
exists: function(){
return this.length === 0 ? 0 : this.length;
}
});
function roundFloat(num,dec){
var d = 1;
for (var i=0; i<dec; i++){
d += "0";
}
return Math.round(num * d) / d;
}
function refreshElement( elem , speed ) //refreshElement('.videoPlayer','slow');
{
var data = $( elem ).html();
$( elem ).empty().html( data ).fadeIn( speed );
}
String.prototype.lpad = function(padString, length) {
var str = this;
while ( str.length < length ) {
str = padString + str; }
return str;
};
String.prototype.formatString = function(){
return this.toString()
.split('!').join(' !').split('!;').join("!important;")
.split(/\s+/g).join(' ')
.split('{').join('{\n\t')
.split('; ').join(';')
.split(';').join(';\n\t')
.split('*/').join('*/\n')
.split(')*(').join(') * (')
.split('}').join('}\n');
};
//myplugin.VideoTitleA("div.thumb .title a",'on');
var VideoTitleA = function( elem , state ){
$( elem ).each(function()
{
var strTitle = $(this).attr('title'),
strText = $(this).attr('data-text'),
strHtml = $(this).text();
state == 'on' ? $(this).text(strTitle).attr('data-text',strHtml) : $(this).text(strText);
});
},
/**
* @return {string}
*/
MultiString = function(f) {
return f.toString().split('\n').slice(1, -1).join('\n');
},
c =
{
defaultState: 3,
logState: function(){
return GM_getValue('LogStateValue');
},
infoState: function(){
return GM_getValue('InfoStateValue');
},
l: function( name, fn, showThis ){
var State = this.logState() || this.defaultState;
( State !== 0 && State === (showThis || State) || State === 'all' ) &&
window.console.log( name, fn !== undefined ? fn : '' );
},
i: function( name, fn, showThis ){
var State = this.infoState() || this.defaultState;
( State !== 0 && State === (showThis || State) || State === 'all' ) &&
window.console.info( name, fn !== undefined ? fn : '' );
}
},
g = {
winLoc : window.location.href,
ms : 0,
timer : function(ms){
g.ms = ms;
setTimeout(function(){ g.ms = 0; },ms);
}
};
c.i('myFunctionLibrary');