Post Reply 
GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
Aug. 13, 2015, 03:17 PM (This post was last modified: Aug. 13, 2015 03:34 PM by cattleyavns.)
Post: #1
GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
.filter:
Code:
FILTER: GM_function
s@(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?</script>))@<script src="https://greasyfork.org/en/scripts/9320-gm-function/code.user.js"></script>\n$1@i

.action, simply global it:
Code:
{+filter{GM_function}}
/

I uploaded the library into my Greasefork's account to serve HTTPS website (by default web browser only allow you embed https content into https website, if http then they will block. Feel free to download and reupload it to your local web server or other file hosting if you want.

Global exclude all js, css to prevent bugs:
.filter
Code:
SERVER-HEADER-TAGGER: content-type
s†^Content-Type:\s(.*)†$1†i
.action
Code:
{+server-header-tagger{content-type}}
/

{-filter}
TAG:^(?:text/css|text/javascript|application)
#WHITELIST
#/.*?\.js(?:$|\?|,|\.)
#/.*?\.css(?:$|\?|,|\.)
TAG:^X-Requested-With
TAG:^application/x-javascript
TAG:^application/javascript
TAG:^text/javascript
TAG:^text/x-

#TAG:^text/css
TAG:^application/json
#/.*?\.json(?:$|\?|,|\.)
#TAG:^video
#TAG:^audio
#/dyn-css/
#WHITELIST

Example, YoutubeCenter without Greasemonkey:
Code:
FILTER: youtubecenter
s@(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?</script>))@n<script>\n\
var imported = document.createElement('script');\n\
imported.src = 'https://github.com/YePpHa/YouTubeCenter/raw/master/dist/YouTubeCenter.user.js';\n\
document.body.appendChild(imported);\n\
</script>\n$1@i

Global it with / . Everytime I say "global" then you will use my filter with / . Just visit Youtube and see the miracle.

More:
Affiliate_killer - Kill redirect tracking method
Code:
FILTER: Affiliate_killer

s†(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?</script>))†\n<script>\n\
window.addEventListener("DOMContentLoaded", Greasemonkey_main, false);\n\
function Greasemonkey_main ()\n\
{\n\
var imported = document.createElement('script');\n\
imported.src = 'https://greasyfork.org/scripts/456-affiliate-killer/code/Affiliate%20killer.user.js';\n\
document.body.appendChild(imported);\n\
}\n\
</script>\n$1†i

Google Translate Tooltip:
Code:
FILTER: Google_Translator_Tooltip_Expanded_Fork
#s†(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?</script>))†<script src='https://code.jquery.com/jquery-1.7.2.min.js'></script>\n$1†i
#s†(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?</script>))†<script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js'></script>\n$1†i
s†(<\/body>|$)†\n<script>\n\
// ==UserScript==\n\
// @name            Google Translate Extended Fork CORS, const fix for Privoxy\n\
// @description        Fixed by me, this version work without Greasemonkey for Privoxy, perfect version.\n\
// @namespace        http://vn-sharing.net/forum/showthread.php?t=2045&p=465220\#post465220\n\
// @homepage            http://vn-sharing.net/forum/showthread.php?t=2045&p=465220\#post465220\n\
// @author          sunflowers\n\
// @version         0.14\n\
// @include            *\n\
// @grant            GM_getValue\n\
// @grant            GM_xmlhttpRequest\n\
// @grant            GM_log\n\
// @grant            GM_deleteValue\n\
// @grant            GM_addStyle\n\
// @grant            GM_openInTab\n\
// @grant            GM_registerMenuCommand\n\
// @grant            GM_setValue\n\
// ==/UserScript==\n\
\n\
\n\
function runscriptgtefc() {\n\
var HREF_NO = 'javascript:void(0)';\n\
initCrossBrowserSupportForGmFunctions();\n\
var languagesGoogle = '<option value="auto">Detect language</option><option value="af">Afrikaans</option><option value="sq">Albanian</option><option value="ar">Arabic</option><option value="hy">Armenian</option><option value="az">Aerbaijani</option><option value="eu">Basque</option><option value="be">Belarusian</option><option value="bn">Bengali</option><option value="bg">Bulgarian</option><option value="ca">Catalan</option><option value="zh-CN">Chinese (simplified)</option><option value="zh-TW">Chinese (traditional)</option><option value="hr">Croatian</option><option value="cs">Czech</option><option value="da">Danish</option><option value="nl">Dutch</option><option value="en">English</option><option value="et">Estonian</option><option value="tl">Filipino</option><option value="fi">Finnish</option><option value="fr">French</option><option value="gl">Galician</option><option value="ka">Georgian</option><option value="de">German</option><option value="el">Greek</option><option value="ht">Haitian Creole</option><option value="iw">Hebrew</option><option value="hi">Hindi</option><option value="hu">Hungarian</option><option value="is">Icelandic</option><option value="id">Indonesian</option><option value="ga">Irish</option><option value="it">Italian</option><option  value="ja">Japanese</option><option value="ko">Korean</option><option value="lv">Latvian</option><option value="lt">Lithuanian</option><option value="mk">Macedonian</option><option value="ms">Malay</option><option value="mt">Maltese</option><option value="no">Norwegian</option><option value="fa">Persian</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sr">Serbian</option><option value="sk">Slovak</option><option  value="sl">Slovenian</option><option value="es">Spanish</option><option value="sw">Swahili</option><option value="sv">Swedish</option><option value="th">Thai</option><option value="tr">Turkish</option><option value="uk">Ukrainian</option><option value="ur">Urdu</option><option value="vi">Vietnamese</option><option value="cy">Welsh</option><option value="yi">Yiddish</option>';\n\
var body = getTag('body')[0];\n\
var imgLookup;\n\
var txtSel = encodeURIComponent(txtSel); // text selected\n\
var translation2Element = document.createElement('span');\n\
var currentURL;\n\
var initialized = false;\n\
images();\n\
css();\n\
document.addEventListener('mouseup', showLookupIcon, false);\n\
document.addEventListener('mousedown', mousedownCleaning, false);\n\
function mousedownCleaning(evt) {\n\
    var divDic = getId('divDic');\n\
    var divLookup = getId('divLookup');\n\
    if (divDic) {\n\
        if (!clickedInsideID(evt.target, 'divDic'))\n\
            divDic.parentNode.removeChild(divDic);\n\
    }\n\
    if (divLookup)\n\
        divLookup.parentNode.removeChild(divLookup);\n\
}\n\
function showLookupIcon(evt) {\n\
    if (evt.ctrlKey && evt.altKey && (!GM_getValue('ctrl') || !GM_getValue('alt')))\n\
        return;\n\
    // XOR http://www.howtocreate.co.uk/xor.html\n\
    if (evt.ctrlKey ? !GM_getValue('ctrl') : GM_getValue('ctrl'))\n\
        return;\n\
    if (evt.altKey ? !GM_getValue('alt') : GM_getValue('alt'))\n\
        return;\n\
    if (!initialized) {\n\
        images();\n\
        css();\n\
        initialized = true;\n\
    }\n\
    var divDic = getId('divDic');\n\
    var divLookup = getId('divLookup');\n\
    txtSel = getSelection();\n\
    // Exit if no text is selected\n\
    if (!txtSel || txtSel == "") {\n\
        if (divDic) {\n\
            if (!clickedInsideID(evt.target, 'divDic'))\n\
                divDic.parentNode.removeChild(divDic);\n\
        }\n\
        if (divLookup)\n\
            divLookup.parentNode.removeChild(divLookup);\n\
        return;\n\
    }\n\
    // Possible cleanup\n\
    if (divDic) {\n\
        if (!clickedInsideID(evt.target, 'divDic'))\n\
            divDic.parentNode.removeChild(divDic);\n\
        return;\n\
    }\n\
    // Remove div if exists\n\
    if (divLookup) {\n\
        divLookup.parentNode.removeChild(divLookup);\n\
    }\n\
    // Div container\n\
    divLookup = createElement('div', {\n\
            id : 'divLookup',\n\
            style : 'background-color:transparent; color:\#000000; position:absolute; top:' + (evt.clientY + window.pageYOffset + 10) + 'px; left:' + (evt.clientX + window.pageXOffset + 10) + 'px; padding:0px; z-index:10000; border-radius:2px;'\n\
        });\n\
    divLookup.appendChild(imgLookup.cloneNode(false));\n\
    divLookup.addEventListener('mouseover', lookup, false);\n\
    body.appendChild(divLookup);\n\
}\n\
// Create the tooltip and launch the Google Translate request to get the translation\n\
function lookup(evt) {\n\
    var divResult = null;\n\
    var divDic = getId('divDic');\n\
    var divLookup = getId('divLookup');\n\
    var top = divLookup.style.top;\n\
    var left = divLookup.style.left;\n\
    // No text selected\n\
    if (!txtSel || txtSel == "") {\n\
        if (divDic = getId('divDic'))\n\
            divDic.parentNode.removeChild(divDic);\n\
        return;\n\
    }\n\
    // Cleanup divs\n\
    if (divDic = getId('divDic')) {\n\
        divDic.parentNode.removeChild(divDic);\n\
    }\n\
    divLookup.parentNode.removeChild(divLookup);\n\
    // Div container\n\
    divDic = createElement('div', {\n\
            id : 'divDic',\n\
            style : 'opacity: 1; font-family: "Open Sans", Arial, Helvetica, sans-serif !important; font-size: ' + GM_getValue('fontsize', 'small') + '; background-color: ' + GM_getValue('backgroundColor', '\#EDF4FC') + '; color: ' + GM_getValue('textcolor', 'Gray') + '; position:absolute; top:' + top + '; left:' + left + '; min-width:250px; min-height:50px; max-width:50%; padding:5px; text-align:left; z-index:10000; border-radius:4px; box-shadow: -2px 0px 9px 5px \#898D91'\n\
        });\n\
    divDic.addEventListener('mousedown', dragHandler, false);\n\
    body.appendChild(divDic);\n\
    // Div result\n\
    // This awfull wall of text is the "+" image\n\
    divResult = createElement('div', {\n\
            id : 'divResult',\n\
            style : 'overflow:auto; padding:3px;'\n\
        }, null, '<img src="data:image/gif;base64,R0lGODlh3AATAPQAAP///x4R0cXC8rCr7qei7MC88bq38M7L9Nza98rH89jW9uDe9+Pi+Ofl+bm18MPA8urp+u7t+tDN9PPy+/X0/NPR9fb2/MzJ9NXT9e/v+9rY9snG87Ov7/j4/Kum7aKc6yH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAA3AATAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zv/8CgcEgECAaEpHLJbDqf0Kh0Sq1ar9isdjoQtAQFg8PwKIMHnLF63N2438f0mv1I2O8buXjvaOPtaHx7fn96goR4hmuId4qDdX95c4+RG4GCBoyAjpmQhZN0YGYFXitdZBIVGAoKoq4CG6Qaswi1CBtkcG6ytrYJubq8vbfAcMK9v7q7D8O1ycrHvsW6zcTKsczNz8HZw9vG3cjTsMIYqQgDLAQGCQoLDA0QCwUHqfYSFw/xEPz88/X38Onr14+Bp4ADCco7eC8hQYMAEe57yNCew4IVBU7EGNDiRn8Z831cGLHhSIgdE/9chIeBgDoB7gjaWUWTlYAFE3LqzDCTlc9WOHfm7PkTqNCh54rePDqB6M+lR536hCpUqs2gVZM+xbrTqt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5saXABhlYxiEzHoKoIV8LYqAMaw9aZqFmJUK4YHuNfRjiXhmk+NcyJgaIolvM8BhiBx3IleN8lH1IWAcRgkZgCgYiaBGJojGgHHFTgtagAFYSZhF7/qnTpY+faVlNAnqJN0EHWa6ozAZjBtgmmBokwMB01LW5jAZwbqfmlNips4B4eOqJgDJ2+imXRZpthuigeC6XZTWIxilXmRo8iYKBCwiWmWkJVEAkfB0w8KI1IvlIpKnOkVpqdB5+h96o8d3lFnijrgprjbfGRSt0lH0nAZG5vsprWxYRW6Suq4UWqrLEsspWg8Io6yv/q6EhK0Fw0GLbjKYn5CZYBYht1laPrnEY67kyrhYbuyceiR28Pso7bYwiXjihjWsWuWF5p/H765HmNoiur3RJsGKNG/jq748XMrwmjhwCfO6QD9v7LQsDxPTAMKsFpthyJCdkmgYiw0VdXF/Om9dyv7YMWGXTLYpZg5wNR11C78oW3p8HSGgul4qyrJppgllJHJZHn0Y0yUwDXCXUNquFZNLKyYXBAVZvxtAKYIQEsmPgDacr0tltO1y/DMwYpkgUpJfTasLGzd3cdCN3gN3UWRcY3epIEPevfq+3njBxq/kqBoGBduvea8f393zICS63ivRBTqgFpgaWZEIUULdcK+frIfAAL2AjscXqrLfu+uuwx05FF0XUbvvtuOeu++689+7778AHL/wJIQAAOwAAAAAAAAAAAA=="/><br/>Loading...');\n\
    divDic.appendChild(divResult);\n\
    // Options link\n\
    var optionLink = createElement('a', {\n\
            id : 'optionsLink',\n\
            href : HREF_NO,\n\
            style : 'opacity:0.2; position:absolute; bottom:3px; right:13px; font-size:18px; text-decoration:none!important;background:\#528DDF;padding:1px;color:\#fff;border-radius:6px 6px 6px 6px;border:2px solid \#EEEEEE;font-weight:bold;width:20px;text-align:center;display:block;'\n\
        }, 'click openCloseOptions false', '+');\n\
    divDic.appendChild(optionLink);\n\
    optionLink.addEventListener('mouseover', function (e) {\n\
        e.target.style.opacity = 1.0\n\
    });\n\
    optionLink.addEventListener('mouseout', function (e) {\n\
        e.target.style.opacity = 0.2\n\
    });\n\
    // Send the Google Translate request\n\
    if ((txtSel + " ").search(/^\\s*https?:\\/\\//) > -1) {\n\
        divResult.innerHTML = '<a href="' + txtSel + '" target="_blank" >' + txtSel + '</a>';\n\
    } else if ((txtSel + " ").search(/^\\s*\\S+(\\.\\S+)+/) > -1) // site.dom\n\
    {\n\
        divResult.innerHTML = '<a style="color:\#888;" href="http://' + txtSel + '" target="_blank" >' + txtSel + '</a>';\n\
    } else {\n\
        var sl,\n\
        tl,\n\
        lang;\n\
        sl = GM_getValue('from') ? GM_getValue('from') : "auto";\n\
        tl = GM_getValue('to') ? GM_getValue('to') : "vi";\n\
        lang = sl + "|" + tl;\n\
        //currentURL = "http://www.google.com/translate_t?text=" + encodeURIComponent(txtSel) + "&langpair=" + lang; // Basic address, for web page parsing\n\
        //currentURL = "http://translate.google.com/translate_a/t?client=t&text=" + encodeURIComponent(txtSel) + "&langpair=" + lang; // URL for GET request. This adress return an array as answer\n\
        currentPostData = "client=t&text=" + encodeURIComponent(txtSel) + "&langpair=" + lang; // Data for a POST request, for handling long requests\n\
        GM_xmlhttpRequest({\n\
            /*method: 'GET',\n\
            url: currentURL,*/\n\
            method : 'POST',\n\
            url : 'http://translate.google.com/translate_a/t',\n\
            data : currentPostData,\n\
            headers : {\n\
                'Content-Type' : 'application/x-www-form-urlencoded'\n\
            },\n\
            onload : function (resp) {\n\
                try {\n\
                    extractResult(resp.responseText);\n\
                } catch (e) {\n\
                    GM_log(e);\n\
                }\n\
            }\n\
        });\n\
        if (GM_getValue('to2', 'Disabled') != 'Disabled') {\n\
            sl = GM_getValue('from') ? GM_getValue('from') : "auto";\n\
            tl = GM_getValue('to2') ? GM_getValue('to2') : "auto";\n\
            lang = sl + "|" + tl;\n\
            currentPostData = "client=t&text=" + encodeURIComponent(txtSel) + "&langpair=" + lang; // Data for a POST request, for handling long requests\n\
            GM_xmlhttpRequest({\n\
                method : 'POST',\n\
                url : 'http://translate.google.com/translate_a/t',\n\
                data : currentPostData,\n\
                headers : {\n\
                    'Content-Type' : 'application/x-www-form-urlencoded'\n\
                },\n\
                onload : function (resp) {\n\
                    try {\n\
                        extractResult2(resp.responseText);\n\
                    } catch (e) {\n\
                        GM_log(e);\n\
                    }\n\
                }\n\
            });\n\
        } else {\n\
            translation2Element.innerHTML = '';\n\
        }\n\
    }\n\
}\n\
// Lanched when we select an other language in the setup menu\n\
function quickLookup() {\n\
    getId('divDic').style.fontSize = getId('optFontSize').value;\n\
    getId('divDic').style.color = getId('optTextColor').value;\n\
    getId('divResult').innerHTML = 'Loading...';\n\
    var sl,\n\
    tl,\n\
    lang;\n\
    sl = getId('optSelLangFrom').value;\n\
    tl = getId('optSelLangTo').value;\n\
    lang = sl + "|" + tl;\n\
    currentPostData = "client=t&text=" + encodeURIComponent(txtSel) + "&langpair=" + lang; // Data for a POST request, for handling long requests\n\
    GM_xmlhttpRequest({\n\
        method : 'POST',\n\
        url : 'http://translate.google.com/translate_a/t',\n\
        data : currentPostData,\n\
        headers : {\n\
            'Content-Type' : 'application/x-www-form-urlencoded'\n\
        },\n\
        onload : function (resp) {\n\
            try {\n\
                extractResult(resp.responseText);\n\
            } catch (e) {\n\
                GM_log(e);\n\
            }\n\
        }\n\
    });\n\
    if (getId('optSelLangTo2').value != 'Disabled') {\n\
        var sl,\n\
        tl,\n\
        lang;\n\
        sl = getId('optSelLangFrom').value;\n\
        tl = getId('optSelLangTo2').value;\n\
        currentPostData = "client=t&text=" + encodeURIComponent(txtSel) + "&langpair=" + lang; // Data for a POST request, for handling long requests\n\
        GM_xmlhttpRequest({\n\
            method : 'POST',\n\
            url : 'http://translate.google.com/translate_a/t',\n\
            data : currentPostData,\n\
            headers : {\n\
                'Content-Type' : 'application/x-www-form-urlencoded'\n\
            },\n\
            onload : function (resp) {\n\
                try {\n\
                    extractResult2(resp.responseText);\n\
                } catch (e) {\n\
                    GM_log(e);\n\
                }\n\
            }\n\
        });\n\
    } else {\n\
        translation2Element.innerHTML = '';\n\
    }\n\
}\n\
function extractResult(gTradStringArray) {\n\
    var arr = eval(gTradStringArray); // eval is used to transform the string to an array. I alse made a custom parsing function, but it doesn't handle antislashed characters, so I prefer using eval()\n\
    /*\n\
    Content of the gTrad array :\n\
    0 / 0:Translation 1:Source text\n\
    1 / i:Grammar / 0:Types (word, verb, ...) 1: Other translations\n\
    5 / Array of other translations\n\
     */\n\
    var translation = '';\n\
    // 0 - Full translation\n\
    translation += '<small><a href="https://translate.google.com/\#' + GM_getValue('from', 'auto') + '/' + GM_getValue('to', 'vi') + '/' + txtSel + '">[' + arr[2] + '] ';\n\
    for (var i = 0; i < arr[0].length; i++)\n\
        translation += arr[0][i][1];\n\
    translation += '</a> <span id="texttospeachbuttonfrom"></span></small><br/>';\n\
    translation += '[' + GM_getValue('to', 'vi') + ']<em> ';\n\
    for (var i = 0; i < arr[0].length; i++)\n\
        translation += arr[0][i][0];\n\
    translation += '</em> <span id="texttospeachbuttonto"></span><br/><span id="translation2Element"></span><br/>';\n\
    translation += '<a id="toggleShowDetails" ' + (!GM_getValue('details', 'false') ? 'style="display:none"' : '') + '>Show details</a>';\n\
    translation += '<span id="divDetails" ' + (GM_getValue('details', 'false') ? 'style="display:none"' : '') + '><a id="toggleHideDetails">Hide details</a><br/>';\n\
    // 1 - Grammar\n\
    if (typeof arr[1] != 'undefined') {\n\
        for (var i = 0; i < arr[1].length; i++) {\n\
            translation += '<strong>' + arr[1][i][0] + ' : </strong>';\n\
            for (var j = 0; j < arr[1][i][1].length; j++) {\n\
                translation += ((j == 0) ? '' : ', ') + arr[1][i][1][j];\n\
            }\n\
            translation += '<br/>';\n\
        }\n\
        translation += '<br/>';\n\
    }\n\
    // 5 - Alternative parts\n\
    if (typeof arr[5] != 'undefined') {\n\
        for (var i = 0; i < arr[5].length; i++) {\n\
            if (typeof arr[5][i][2] != 'undefined') { // 5/i/2 array of alternatives, 5/i/0 the part of the text we are studying\n\
                translation += '<strong>' + arr[5][i][0] + ' : </strong>';\n\
                for (var j = 0; j < arr[5][i][2].length; j++) {\n\
                    translation += ((j == 0) ? '' : ', ') + arr[5][i][2][j][0];\n\
                }\n\
                translation += '<br/>';\n\
            }\n\
        }\n\
    }\n\
    translation += '</span>'; // Detail end\n\
    getId('divResult').innerHTML = '<p style="margin:0px">' + translation + '</p>';\n\
    getId('translation2Element').appendChild(translation2Element); // Optional second translation\n\
    getId('toggleShowDetails').addEventListener('click', function () {\n\
        getId('toggleShowDetails').style.display = 'none';\n\
        getId('divDetails').style.display = 'block';\n\
    }, false);\n\
    getId('toggleHideDetails').addEventListener('click', function () {\n\
        getId('toggleShowDetails').style.display = 'inline';\n\
        getId('divDetails').style.display = 'none';\n\
    }, false);\n\
    // Create the Text to Speach\n\
    var fromText = '';\n\
    var toText = '';\n\
    for (var i = 0; i < arr[0].length; i++)\n\
        fromText += arr[0][i][1];\n\
    for (var i = 0; i < arr[0].length; i++)\n\
        toText += arr[0][i][0];\n\
    addTextToSpeachLink(getId('texttospeachbuttonfrom'), arr[2], fromText); // arr[2] contains the detected input language\n\
    addTextToSpeachLink(getId('texttospeachbuttonto'), GM_getValue('to', 'auto') == 'auto' ? 'en' : GM_getValue('to', 'auto'), toText); // I cannot find a way to get the detected destination language, so if the requested destination is 'auto', I use the english Text to Speach language\n\
}\n\
function extractResult2(gTradStringArray) {\n\
    var arr = eval(gTradStringArray);\n\
    var translation = '';\n\
    translation += '\#[' + GM_getValue('to2', 'auto') + ']<em> ';\n\
    for (var i = 0; i < arr[0].length; i++)\n\
        translation += arr[0][i][0];\n\
    translation += '</em>\# <span id="texttospeachbuttonto2"></span>';\n\
    translation2Element.innerHTML = translation;\n\
    var toText2 = '';\n\
    for (var i = 0; i < arr[0].length; i++)\n\
        toText2 += arr[0][i][0];\n\
    addTextToSpeachLink(getId('texttospeachbuttonto2'), GM_getValue('to2', 'auto') == 'auto' ? 'en' : GM_getValue('to2', 'auto'), toText2);\n\
}\n\
function addTextToSpeachLink(element, lang, text) {\n\
    if (GM_getValue('tts', true) == false)\n\
        return;\n\
    var speachLink = document.createElement('a');\n\
    //speachLink.href = 'http://translate.google.com/translate_tts?tl=' + lang + '&q=' + text.replace(/[«»'"]/g, ' ');\n\
    link = 'http://translate.google.com/translate_tts?tl=' + lang + '&q=' + text.replace(/[«»'"]/g, ' ');\n\
    //alert(link);\n\
        speachLink.href = 'javascript:void();';\n\
        speachLink.setAttribute("onclick", 'elem = document.createElement("audio");elem.src = "' + link + '";elem.type = "audio/mpeg";elem.autoplay = "true";document.body.appendChild(elem);document.body.removeChild(elem);');\n\
    //speachLink.target = '_blank';\n\
    //speachLink.innerHTML = '<img src="http://translate.google.com/favicon.ico" onclick=createaudio(\\"' + link + '\\") height="16" width="16"/>';\n\
    speachLink.innerHTML = '<img src="http://translate.google.com/favicon.ico" height="16" width="16"/>';\n\
    element.appendChild(speachLink);\n\
}\n\
/*\n\
function createaudio(audio) {\n\
elem = document.createElement("audio");\n\
elem.src = audio;\n\
elem.type = "audio/mpeg";\n\
elem.autoplay = "true";\n\
document.body.appendChild(elem);\n\
//document.body.removeChild(elem);\n\
}\n\
*/\n\
function getSelection() {\n\
    var txt = null;\n\
    //get selected text\n\
    if (window.getSelection && !window.opera) // window.getSelection() bugs with Opera 12.16 and ViolentMonkey\n\
    {\n\
        txt = window.getSelection();\n\
    } else if (document.getSelection) {\n\
        txt = document.getSelection();\n\
    } else if (document.selection) {\n\
        txt = document.selection.createRange().text;\n\
    }\n\
    return txt;\n\
}\n\
function openCloseOptions(evt) {\n\
    var divOptions = getId('divOpt');\n\
    if (!divOptions) //Show options\n\
    {\n\
        divOptions = createElement('div', {\n\
                id : 'divOpt',\n\
                style : 'border-top:2px solid \#5A91D8;position:relative; padding:5px;'\n\
            });\n\
        getId('divDic').appendChild(divOptions);\n\
        getId('optionsLink').style.visibility = 'hidden';\n\
        /*// color picker, the library doesn't work on Opera\n\
        try {\n\
            if (!window.divColorPicker) {\n\
                window.divColorPicker = createElement('div', {\n\
                        id : 'optPicker',\n\
                        class : 'cp-small'\n\
                    });\n\
                window.colorPicker = ColorPicker(\n\
                        window.divColorPicker,\n\
                        function (hex, hsv, rgb) {\n\
                        getId('divDic').style.backgroundColor = hex;\n\
                    });\n\
            }\n\
            window.colorPicker.setHex(GM_getValue('backgroundColor', '\#EDF4FC'));\n\
            divOptions.appendChild(window.divColorPicker);\n\
        } catch (err) {\n\
            divOptions.innerHTML += '<p>Error : Cannot load color picker (Known issue on Opera)</p>';\n\
        }*/\n\
        //fields container\n\
        divOptionsFields = createElement('p');\n\
        divOptions.appendChild(divOptionsFields);\n\
        //from\n\
        divOptionsFields.appendChild(createElement('span', null, null, 'From :'));\n\
        divOptionsFields.appendChild(createElement('select', {\n\
                id : 'optSelLangFrom'\n\
            }, null, languagesGoogle));\n\
        getId('optSelLangFrom').value = GM_getValue('from') ? GM_getValue('from') : 'auto';\n\
        getId('optSelLangFrom').addEventListener('change', quickLookup, false);\n\
        //to\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('span', null, null, ' To :'));\n\
        divOptionsFields.appendChild(createElement('select', {\n\
                id : 'optSelLangTo'\n\
            }, null, languagesGoogle));\n\
        getId('optSelLangTo').value = GM_getValue('to') ? GM_getValue('to') : 'vi';\n\
        getId('optSelLangTo').addEventListener('change', quickLookup, false);\n\
        //to2\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('span', null, null, ' To 2 :'));\n\
        divOptionsFields.appendChild(createElement('select', {\n\
                id : 'optSelLangTo2'\n\
            }, null, '<option value="Disabled">Disabled</option>' + languagesGoogle));\n\
        getId('optSelLangTo2').value = GM_getValue('to2') ? GM_getValue('to2') : 'Disabled';\n\
        getId('optSelLangTo2').addEventListener('change', quickLookup, false);\n\
        //use text to speach\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('input', {\n\
                id : 'checkTTS',\n\
                type : 'checkbox'\n\
            }));\n\
        divOptionsFields.appendChild(createElement('span', null, null, '<span title="The feature has many issues. You often have to refresh the page to launch the .mp3 file. If you use the langage auto-detection, you have to change the langage in the url of the new tab." style="border-bottom:1px dashed">Display Text To Speach</span>'));\n\
        getId('checkTTS').checked = GM_getValue('tts') ? GM_getValue('tts') : 'true';\n\
        //hide details\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('input', {\n\
                id : 'checkDetails',\n\
                type : 'checkbox'\n\
            }));\n\
        divOptionsFields.appendChild(createElement('span', null, null, 'Hide details by default'));\n\
        getId('checkDetails').checked = GM_getValue('details');\n\
        //font size\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('span', null, null, 'Font size :'));\n\
        divOptionsFields.appendChild(createElement('select', {\n\
                id : 'optFontSize'\n\
            }, null, '<option value="x-small">Extra small</option><option value="small">Small (default)</option><option value="medium">Medium</option><option value="large">Large</option>'));\n\
        getId('optFontSize').value = GM_getValue('fontsize') ? GM_getValue('fontsize') : 'small';\n\
        getId('optFontSize').addEventListener('change', quickLookup, false);\n\
        //text color\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('span', null, null, 'Text color :'));\n\
        divOptionsFields.appendChild(createElement('select', {\n\
                id : 'optTextColor'\n\
            }, null, '<option value="Gray">Gray (default)</option><option value="Black">Black</option><option value="White">White</option><option value="CadetBlue">CadetBlue</option><option value="ForestGreen">ForestGreen</option><option value="FireBrick">FireBrick</option>'));\n\
        getId('optTextColor').value = GM_getValue('textcolor') ? GM_getValue('textcolor') : 'Gray';\n\
        getId('optTextColor').addEventListener('change', quickLookup, false);\n\
        //use ctrl\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('input', {\n\
                id : 'checkCtrl',\n\
                type : 'checkbox'\n\
            }));\n\
        divOptionsFields.appendChild(createElement('span', null, null, 'Use Ctrl key'));\n\
        getId('checkCtrl').checked = GM_getValue('ctrl');\n\
        //use alt\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('input', {\n\
                id : 'checkAlt',\n\
                type : 'checkbox'\n\
            }));\n\
        divOptionsFields.appendChild(createElement('span', null, null, 'Use Alt key'));\n\
        getId('checkAlt').checked = GM_getValue('alt');\n\
        //save\n\
        divOptionsFields.appendChild(createElement('br'));\n\
        divOptionsFields.appendChild(createElement('a', {\n\
                href : HREF_NO,\n\
                class : "gootranslink"\n\
            }, 'click saveOptions false', 'Save'));\n\
        //reset\n\
        divOptionsFields.appendChild(createElement('span', null, null, ' - '));\n\
        divOptionsFields.appendChild(createElement('a', {\n\
                href : HREF_NO,\n\
                class : "gootranslink"\n\
            }, 'click resetOptions false', 'Reset'));\n\
        //cancel\n\
        divOptionsFields.appendChild(createElement('span', null, null, ' - '));\n\
        divOptionsFields.appendChild(createElement('a', {\n\
                href : HREF_NO,\n\
                class : "gootranslink"\n\
            }, 'click openCloseOptions false', 'Cancel'));\n\
    } else // Hide options\n\
    {\n\
        divOptions.parentNode.removeChild(divOptions);\n\
        getId('optionsLink').style.visibility = 'visible';\n\
    }\n\
}\n\
function saveOptions(evt) {\n\
    var backgroundColor = getId('divDic').style.backgroundColor;\n\
    var from = getId('optSelLangFrom').value;\n\
    var to = getId('optSelLangTo').value;\n\
    var to2 = getId('optSelLangTo2').value;\n\
    var tts = getId('checkTTS').checked;\n\
    var details = getId('checkDetails').checked;\n\
    var fontsize = getId('optFontSize').value;\n\
    var textcolor = getId('optTextColor').value;\n\
    var ctrl = getId('checkCtrl').checked;\n\
    var alt = getId('checkAlt').checked;\n\
    GM_setValue('backgroundColor', backgroundColor);\n\
    GM_setValue('from', from);\n\
    GM_setValue('to', to);\n\
    GM_setValue('to2', to2);\n\
    GM_setValue('tts', tts);\n\
    GM_setValue('details', details);\n\
    GM_setValue('fontsize', fontsize);\n\
    GM_setValue('textcolor', textcolor);\n\
    GM_setValue('ctrl', ctrl);\n\
    GM_setValue('alt', alt);\n\
    quickLookup();\n\
    getId('divDic').removeChild(getId('divOpt'));\n\
    getId('optionsLink').style.visibility = 'visible';\n\
}\n\
function resetOptions(evt) {\n\
    GM_deleteValue('backgroundColor');\n\
    GM_deleteValue('from');\n\
    GM_deleteValue('to');\n\
    GM_deleteValue('to2');\n\
    GM_deleteValue('tts');\n\
    GM_deleteValue('fontsize');\n\
    GM_deleteValue('textcolor');\n\
    GM_deleteValue('ctrl');\n\
    GM_deleteValue('alt');\n\
    getId('divDic').parentNode.removeChild(getId('divDic'));\n\
}\n\
function css() {\n\
    var style = createElement('style', {\n\
            type : "text/css"\n\
        }, null, "" +\n\
            'a.gootranslink:link {color: \#0000FF !important; text-decoration: underline !important;}' +\n\
            'a.gootranslink:visited {color: \#0000FF !important; text-decoration: underline !important;}' +\n\
            'a.gootranslink:hover {color: \#0000FF !important; text-decoration: underline !important;}' +\n\
            'a.gootranslink:active {color: \#0000FF !important; text-decoration: underline !important;}' +\n\
            '.picker-wrapper,.slide-wrapper{position:relative;float:left}.picker-indicator,.slide-indicator{position:absolute;left:0;top:0;pointer-events:none}.picker,.slide{cursor:crosshair;float:left}.cp-default{background-color:gray;padding:12px;box-shadow:0 0 40px \#000;border-radius:15px;float:left}.cp-default .picker{width:200px;height:200px}.cp-default .slide{width:30px;height:200px}.cp-default .slide-wrapper{margin-left:10px}.cp-default .picker-indicator{width:5px;height:5px;border:2px solid darkblue;-moz-border-radius:4px;-o-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;opacity:.5;-ms-filter:"alpha(opacity=50)";filter:alpha(opacity=50);filter:alpha(opacity=50);background-color:white}.cp-default .slide-indicator{width:100%;height:10px;left:-4px;opacity:.6;-ms-filter:"alpha(opacity=60)";filter:alpha(opacity=60);filter:alpha(opacity=60);border:4px solid lightblue;-moz-border-radius:4px;-o-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;background-color:white}.cp-small{padding:5px;background-color:white;float:left;border-radius:5px}.cp-small .picker{width:100px;height:100px}.cp-small .slide{width:15px;height:100px}.cp-small .slide-wrapper{margin-left:5px}.cp-small .picker-indicator{width:1px;height:1px;border:1px solid black;background-color:white}.cp-small .slide-indicator{width:100%;height:2px;left:0;background-color:black}.cp-fancy{padding:10px;background:-webkit-linear-gradient(top,\#aaa 0,\#222 100%);float:left;border:1px solid \#999;box-shadow:inset 0 0 10px white}.cp-fancy .picker{width:200px;height:200px}.cp-fancy .slide{width:30px;height:200px}.cp-fancy .slide-wrapper{margin-left:10px}.cp-fancy .picker-indicator{width:24px;height:24px;background-image:url(http://cdn1.iconfinder.com/data/icons/fugue/bonus/icons-24/target.png)}.cp-fancy .slide-indicator{width:30px;height:31px;left:30px;background-image:url(http://cdn1.iconfinder.com/data/icons/bluecoral/Left.png)}.cp-normal{padding:10px;background-color:white;float:left;border:4px solid \#d6d6d6;box-shadow:inset 0 0 10px white}.cp-normal .picker{width:200px;height:200px}.cp-normal .slide{width:30px;height:200px}.cp-normal .slide-wrapper{margin-left:10px}.cp-normal .picker-indicator{width:5px;height:5px;border:1px solid gray;opacity:.5;-ms-filter:"alpha(opacity=50)";filter:alpha(opacity=50);filter:alpha(opacity=50);background-color:white;pointer-events:none}.cp-normal .slide-indicator{width:100%;height:10px;left:-4px;opacity:.6;-ms-filter:"alpha(opacity=60)";filter:alpha(opacity=60);filter:alpha(opacity=60);border:4px solid gray;background-color:white;pointer-events:none}');\n\
    getTag('head')[0].appendChild(style);\n\
}\n\
/*\n\
* Short functions to replace the document.createElement document.getElementById and document.getElementsByTagName\n\
*/\n\
function createElement(type, attrArray, evtListener, html) {\n\
    var node = document.createElement(type);\n\
    for (var attr in attrArray)\n\
        if (attrArray.hasOwnProperty(attr)) {\n\
            node.setAttribute(attr, attrArray[attr]);\n\
        }\n\
    if (evtListener) {\n\
        var a = evtListener.split(' ');\n\
        node.addEventListener(a[0], eval(a[1]), eval(a[2]));\n\
    }\n\
    if (html)\n\
        node.innerHTML = html;\n\
    return node;\n\
}\n\
function getId(id, parent) {\n\
    if (!parent)\n\
        return document.getElementById(id);\n\
    return parent.getElementById(id);\n\
}\n\
function getTag(name, parent) {\n\
    if (!parent)\n\
        return document.getElementsByTagName(name);\n\
    return parent.getElementsByTagName(name);\n\
}\n\
/*\n\
* Drag and drop support adapted from http://www.hunlock.com/blogs/Javascript_Drag_and_Drop\n\
*/\n\
var savedTarget = null; // The target layer (effectively vidPane)\n\
var orgCursor = null; // The original mouse style so we can restore it\n\
var dragOK = false; // True if we're allowed to move the element under mouse\n\
var dragXoffset = 0; // How much we've moved the element on the horozontal\n\
var dragYoffset = 0; // How much we've moved the element on the verticle\n\
var didDrag = false; // Set to true when we do a drag\n\
function moveHandler(e) {\n\
    if (e == null)\n\
        return; // { e = window.event }\n\
    if (e.button <= 1 && dragOK) {\n\
        savedTarget.style.left = e.clientX - dragXoffset + 'px';\n\
        savedTarget.style.top = e.clientY - dragYoffset + 'px';\n\
        return false;\n\
    }\n\
}\n\
function dragCleanup(e) {\n\
    document.removeEventListener('mousemove', moveHandler, false);\n\
    document.removeEventListener('mouseup', dragCleanup, false);\n\
    savedTarget.style.cursor = orgCursor;\n\
    dragOK = false; // Its been dragged now\n\
    didDrag = true;\n\
}\n\
function dragHandler(e) {\n\
    var htype = '-moz-grabbing';\n\
    if (e == null)\n\
        return; // { e = window.event;}  // htype='move';}\n\
    var target = e.target; // != null ? e.target : e.srcElement;\n\
    orgCursor = target.style.cursor;\n\
    if (target.nodeName != 'DIV' && target.nodeName != 'P')\n\
        return;\n\
    if (target = clickedInsideID(target, 'divDic')) {\n\
        savedTarget = target;\n\
        target.style.cursor = htype;\n\
        dragOK = true;\n\
        dragXoffset = e.clientX - target.offsetLeft;\n\
        dragYoffset = e.clientY - target.offsetTop;\n\
        // Set the left before removing the right\n\
        target.style.left = e.clientX - dragXoffset + 'px';\n\
        target.style.right = null;\n\
        document.addEventListener('mousemove', moveHandler, false);\n\
        document.addEventListener('mouseup', dragCleanup, false);\n\
        return false;\n\
    }\n\
}\n\
function clickedInsideID(target, id) {\n\
    if (target.getAttribute('id') == id)\n\
        return getId(id);\n\
    if (target.parentNode) {\n\
        while (target = target.parentNode) {\n\
            try {\n\
                if (target.getAttribute('id') == id)\n\
                    return getId(id);\n\
            } catch (e) {}\n\
        }\n\
    }\n\
    return null;\n\
}\n\
// End drag code\n\
/*\n\
* Images\n\
*/\n\
function images() {\n\
    imgLookup = createElement('img', {\n\
            border : 0\n\
        });\n\
    imgLookup.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABs0lEQVQ4jY2SP4viQBiHX0UQWz/AXb+VX8Iu/YqFhdhcd5BKEOTKC9jJFYrFgo3FIjYiCRauhTCQDMp4bJFklzCuLJLOWNj8rpDMJt7u7Q08xQzze953/hAR0el4QJLw8KR4fXkE/Wtch01zjP6gmxLsd9uPJafjAf1BF82WjmZLR61eRa1eVfNmS4cMxP8JksGk6FPB6XjAii1Qq1fBBYMMBL79+InvDIrbB0CzIpSmQHF0RnF0vkiTFxZX7A+6MOzwU0FxdEZKYJpj1fp1eO5KzF0JzYreF/iekzr77QMUhh2q1zDsUIULPQl6fXkEFww53cWKLWCaY3DBVMuaFWHuSsT7fM/5W5DTXYUMBGQgUJoCpelFst9tcc84DDuE7znQrAiFnrwIkuGY/W6rBIYdQgYC7RmHZkXwPQf3jL8JiCglISLKVCaqzfhZfc9RcMFwc/eMfGd9EWQbS+R0F9nGEtnGEpnKBJnKJFWxPNygPNygPePggqE942nBdTjG9xyUhxvVcqEnsWILrNjiTfCRJN9ZI99Zp8LxWsy73ztTmYCI6ObuGV/7Tym+/PqtICL6A7F/dNYyWabFAAAAAElFTkSuQmCC';\n\
}\n\
if (typeof GM_deleteValue == 'undefined') {\n\
    GM_addStyle = function (css) {\n\
        var style = document.createElement('style');\n\
        style.textContent = css;\n\
        document.getElementsByTagName('head')[0].appendChild(style);\n\
    }\n\
    GM_deleteValue = function (name) {\n\
        localStorage.removeItem(name);\n\
    }\n\
    GM_getValue = function (name, defaultValue) {\n\
        var value = localStorage.getItem(name);\n\
        if (!value)\n\
            return defaultValue;\n\
        var type = value[0];\n\
        value = value.substring(1);\n\
        switch (type) {\n\
        case 'b':\n\
            return value == 'true';\n\
        case 'n':\n\
            return Number(value);\n\
        default:\n\
            return value;\n\
        }\n\
    }\n\
    GM_log = function (message) {\n\
        console.log(message);\n\
    }\n\
    GM_openInTab = function (url) {\n\
        return window.open(url, "_blank");\n\
    }\n\
    GM_registerMenuCommand = function (name, funk) {\n\
        //todo\n\
    }\n\
    GM_setValue = function (name, value) {\n\
        value = (typeof value)[0] + value;\n\
        localStorage.setItem(name, value);\n\
    }\n\
}\n\
/*\n\
* Cross browser support for GM functions\n\
* http://userscripts.org/topics/41177\n\
*/\n\
function initCrossBrowserSupportForGmFunctions() {\n\
    if (typeof GM_deleteValue == 'undefined') {\n\
        GM_addStyle = function (css) {\n\
            var style = document.createElement('style');\n\
            style.textContent = css;\n\
            document.getElementsByTagName('head')[0].appendChild(style);\n\
        }\n\
        GM_deleteValue = function (name) {\n\
            localStorage.removeItem(name);\n\
        }\n\
        GM_getValue = function (name, defaultValue) {\n\
            var value = localStorage.getItem(name);\n\
            if (!value)\n\
                return defaultValue;\n\
            var type = value[0];\n\
            value = value.substring(1);\n\
            switch (type) {\n\
            case 'b':\n\
                return value == 'true';\n\
            case 'n':\n\
                return Number(value);\n\
            default:\n\
                return value;\n\
            }\n\
        }\n\
        GM_log = function (message) {\n\
            console.log(message);\n\
        }\n\
        GM_openInTab = function (url) {\n\
            return window.open(url, "_blank");\n\
        }\n\
        GM_registerMenuCommand = function (name, funk) {\n\
            //todo\n\
        }\n\
        GM_setValue = function (name, value) {\n\
            value = (typeof value)[0] + value;\n\
            localStorage.setItem(name, value);\n\
        }\n\
    }\n\
}\n\
}\n\
runscriptgtefc();\n\
</script>\n$1†i

Need my cors header filter:
.filter:
Code:
SERVER-HEADER-FILTER: cors
s†^Access-Control-Allow-Origin:.*?$††i
s†^HTTP.*†$0\r\nAccess-Control-Allow-Origin: *†i

.action:
Code:
{+server-header-filter{cors} +hide-referer{block} +crunch-client-header{Origin:}}
.wedata.net
.translate.google*.
127.0.0.1
raw.github*.

to bypass browser's CORS rule.

Screenshot:
[Image: hJ3FVG1.jpg]

Good luck! This is the power of Privoxy.
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to cattleyavns for this post:
Faxopita
Aug. 14, 2015, 10:23 AM
Post: #2
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
I'm just amazed by your post. Now, it's time for me to digest the content… Thanks to you, I know realise the extreme power of Privoxy.
Add Thank You Quote this message in a reply
Aug. 14, 2015, 01:47 PM
Post: #3
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
Thank you, glad that you like my post, please feel free to ask me any question if you have any problem.
Add Thank You Quote this message in a reply
Feb. 06, 2016, 06:01 PM (This post was last modified: Feb. 06, 2016 06:05 PM by Faxopita.)
Post: #4
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
Content digested… Took me a while. You allowed me to discover YoutubeCenter. Indeed, very good and practical. Thank you. Thanks for your other filters as well. They've been successfully integrated into my configuration.
Add Thank You Quote this message in a reply
Feb. 07, 2016, 01:11 PM
Post: #5
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
(Aug. 13, 2015 03:17 PM)cattleyavns Wrote:  Need my cors header filter:
.filter:
Code:
SERVER-HEADER-FILTER: cors
s†^Access-Control-Allow-Origin:.*?$††i
s†^HTTP.*†$0\r\nAccess-Control-Allow-Origin: *†i

.action:
Code:
{+server-header-filter{cors} +hide-referer{block} +crunch-client-header{Origin:}}
.wedata.net
.translate.google*.
127.0.0.1
raw.github*.

to bypass browser's CORS rule.

Hello Cattleyavns. Why would you want to override the browser's CORS rule specifically on those entries? Is that really necessary? Could you please be more verbose on this rule set? Thank you.
Add Thank You Quote this message in a reply
Feb. 07, 2016, 03:31 PM
Post: #6
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
(Feb. 07, 2016 01:11 PM)Faxopita Wrote:  Hello Cattleyavns. Why would you want to override the browser's CORS rule specifically on those entries? Is that really necessary? Could you please be more verbose on this rule set? Thank you.

GM_XMLHTTPRequest needs those rule to work if we want to work with 3rd party domain, for example from prxbx.com we want to use translate.google.com to translate something.
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to cattleyavns for this post:
Faxopita
Feb. 28, 2016, 10:10 PM
Post: #7
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
hey guys,

is it possible that adding .js files with privoxy does break some sites? i am using safari on os x and sometimes the sites are a bit different or the browser does not load the full site?!
Add Thank You Quote this message in a reply
Feb. 29, 2016, 02:24 PM (This post was last modified: Feb. 29, 2016 02:29 PM by cattleyavns.)
Post: #8
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
(Feb. 28, 2016 10:10 PM)kik0s Wrote:  hey guys,

is it possible that adding .js files with privoxy does break some sites? i am using safari on os x and sometimes the sites are a bit different or the browser does not load the full site?!

I don't think .js file can break websites unless it causes connection problem, for example it redownload .js file but the server that serve that .js file is overloaded. You can fix this problem easily by forcing web browser store .js file in disk/memory but never redownload it.

This filter, BetterCache:

Code:
SERVER-HEADER-FILTER: bettercache
#Remove Cache-Control header
s†^Cache-Control:.*††i
#Re-Add Cache-Control header, but max-age=7777777,s-maxage=7777777 will make web browser cache contents forever
s†^HTTP.*†$0\r\nCache-Control: no-transform,public,max-age=7777777,s-maxage=7777777†i

Very easy to use, just:

Code:
{+server-header-filter{bettercache}}
.greasyfork.org/.*?\.user.js$
.userscripts-mirror.org/.*?\.js$
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to cattleyavns for this post:
Faxopita
Jul. 16, 2018, 08:36 PM
Post: #9
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
would it possible to make this addon https://github.com/hyperfekt/webextensio...e-redirect be loaded and working trough privoxy? I looked through 5 pages of results of redirect removers from greasyfork.org, but I was unable to find one that worked just like this one.
Add Thank You Quote this message in a reply
Jul. 21, 2018, 10:10 PM
Post: #10
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
(Jul. 16, 2018 08:36 PM)ryszardzonk Wrote:  would it possible to make this addon https://github.com/hyperfekt/webextensio...e-redirect be loaded and working trough privoxy? I looked through 5 pages of results of redirect removers from greasyfork.org, but I was unable to find one that worked just like this one.

The "webextension-remove-redirect" is quite complicated, I suggest to use an alternative instead.
Yeah,I also have the same problem as you, searched all script from Greasyfork and nothing work as I expected so I decide to write my own, try it and let me know if it work as you want Big Teeth

Code:
Code:
FILTER: redirectremover2
s†(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?<\/script>))†\n<script>\n\
window.addEventListener("DOMContentLoaded", Greasemonkey_main, false);\n\
function Greasemonkey_main ()\n\
{\n\
(function(){\n\
  var k,x,t,i,j,p;\n\
   for(k=0;x=document.links[k];k++){\n\
    t=x.href.replace(/[%]3A/ig,':').replace(/[%]2f/ig,'/');\n\
    i=t.lastIndexOf('http');\n\
    if(i>0){\n\
       t=t.substring(i);\n\
       j=t.indexOf('&');\n\
       if(j>0)t=t.substring(0,j);\n\
       p=/https?\\:\\/\\/[^\\s]*[^.,;'">\\s\\)\\]]/.exec(unescape(t));\n\
       if(p) x.href=p[0];\n\
       \n\
    }\n\
     else if (x.onmouseover&&x.onmouseout){\n\
      x.onmouseover();\n\
       if (window.status && window.status.indexOf('://')!=-1)x.href=window.status;\n\
       x.onmouseout();\n\
       \n\
    }\n\
     x.onmouseover=null;\n\
     x.onmouseout=null;\n\
     \n\
  }\n\
}\n\
)();\n\
}\n\
</script>\n$1†i

Apply on all page:
Code:
{+filter{redirectremover2}}
/
Add Thank You Quote this message in a reply
Jul. 23, 2018, 10:27 PM
Post: #11
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
Yes sir! Redirectremover2 works really well.
Add Thank You Quote this message in a reply
Jul. 26, 2018, 10:04 PM
Post: #12
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
How about running other scripts? I tried to run Adguard

Code:
FILTER: adguardblocker
s@(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?</script>))@<script src="https://greasyfork.org/scripts/33396-adguard-popup-blocker/code/Adguard%20Popup%20Blocker.user.js" type="text/javascript"></script>\n$1@i

That try above resulted in "ReferenceError: unsafeWindow is not defined" leading me into https://developer.mozilla.org/en-US/docs...ot_defined so I tried below method. No error no appeared, but does that even work? No popops/pounders were blocked when I used it.

Code:
FILTER: adguardblocker2
s@(^[^;]*?(?:<head[^>]*?>|<body[^>]*?>|<script[^>]*?>[^>]*?</script>))@\n<script>\n\
window.addEventListener("unsafeWindow", Greasemonkey_main, false);\n\
function Greasemonkey_main ()\n\
{\n\
var imported = document.createElement('script');\n\
imported.src = 'https://192.168.101.101:8447/javascript/adguardblocker_2.1.9.js';\n\
document.body.appendChild(imported);\n\
}\n\
</script>\n$1@i

I got better results with https://greasyfork.org/scripts/24473-pop...er.user.js as it stops popups, but is not all that good solution to use as more clicks are required to get where one want

I also tried a bunch of youtube scripts, but none of them loads on youtube website without giving any error. GM Emulation itself would not load either. Any known reason for that? Firefox otherwise informs about its security related blocks in developer console log.

https://greasyfork.org/scripts/27199-rem...s).user.js
https://greasyfork.org/scripts/10032-byp...on.user.js
https://greasyfork.org/scripts/9062-yout...er.user.js
https://greasyfork.org/scripts/20015-sim...on.user.js
https://greasyfork.org/scripts/5368-yout...20.user.js
https://greasyfork.org/scripts/38675-you...60.user.js
Add Thank You Quote this message in a reply
Aug. 06, 2018, 04:38 PM
Post: #13
RE: GM_function (+example) - Run Greasemonkey script on ALL browser with Privoxy
(Jul. 26, 2018 10:04 PM)ryszardzonk Wrote:  That try above resulted in "ReferenceError: unsafeWindow is not defined" leading me into https://developer.mozilla.org/en-US/docs...ot_defined so I tried below method. No error no appeared, but does that even work? No popops/pounders were blocked when I used it.

unsafeWindow is window in javascript, you can emulate unsafeWindow by adding

unsafeWindows = window;

This should fix the above error, and if I recall correctly, my GM_function.js should emulate unsafeWindow already...
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: