Discussões » Desenvolvimento

please help transform this 3 lines js to GM format

§
Publicado: 04/03/2019

please help transform this 3 lines js to GM format

Hi, years ago I got this javascript from online help, now everything changed and I want to transform it into tampermonkey format. This script is to show original image directly, instead of thumbnail. (by simply remove "thumb=1")

    document.addEventListener('DOMContentLoaded',function(r){
        r=/&thumb=1/;
        [].map.call(this.images,function(t){t.src=t.src.replace(r,'')})
    })

And, the source code of an image's context is like:

<a class="attachthumb flexposts__attachments-attachthumb" href="attachment.php?attachmentid=664897&amp;d=1300711572" rel="Lightbox_" id="attachment664897" target="_blank" title="" style="">
<img height="333" width="625" src="attachment.php?attachmentid=664897&amp;stc=1&amp;thumb=1&amp;d=1365683901" border="0" alt="Click to Enlarge
 Name: eurusd_trade2.png
Size: 116 KB" title="" style=""></a>

Don't know if it's easy? Appreciate any response.

§
Publicado: 02/04/2019
// ==UserScript==
// @name         your script name
// @namespace    anything is ok
// @version      anything is ok
// @description  something your script description  
// @author       your name
// @include      website that you want to run this script,one per include line,such as bellow line will run this script in this page.you can use * for wildcard.add your own include site and delete this line and bellow line
// @include      https://greasyfork.org/zh-CN/forum/discussion/53597/please-help-transform-this-3-lines-js-to-gm-format
// @run-at       document-end
// @notice       as default the script will run at document-end,you can try change up line according to https://wiki.greasespot.net/Metadata_Block#.40run-at if your script didn't run exactly. if you try all the value and the script still did't work,maybe you should change your script
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    document.addEventListener('DOMContentLoaded',function(r){
        r=/&thumb=1/;
        [].map.call(this.images,function(t){t.src=t.src.replace(r,'')})
    })
})();

Publicar resposta

Faça o login para publicar uma resposta.