مۇنازىرىلەر » قۇرۇش تەلىپى

How to remove scripts contains

§
يوللانغان ۋاقتى: 2017-03-31
تەھرىرلەنگەن ۋاقتى: 2017-03-31

How to remove scripts contains

example
script type="text/javascript"
/*

§
يوللانغان ۋاقتى: 2017-04-03

Your script must run before other scripts. Read this. Then just grab all script tags document.getElementsByTagName('script'), loop through them and remove/edit the ones you don't need. Loop in reversed order because removing script tags will mess with indexes.

§
يوللانغان ۋاقتى: 2017-04-04

Firstly thank you ...
If I do document-start var a = document.getElementsByTagName ('script'); Returns 0 if I do document-end it returns 30 ok that part now how do I get what's inside the scripts

§
يوللانغان ۋاقتى: 2017-04-04

My bad. There are no <script> elements at document-start so you need to add a listener. Like this:

// ==UserScript==
// @name        __TEST
// @namespace   tithen-firion
// @include     *
// @version     1
// @run-at      document-start
// ==/UserScript==

window.addEventListener('beforescriptexecute', function(e) {

  // if you want to stop whole <script>
  if(e.target.innerHTML.search(/var .*?=window;/) {
    e.preventDefault();
    e.stopPropagation();
  }

  // if you want to change part of a code
  e.target.innerHTML= e.target.innerHTML.replace(/bla bla bla/, 'bla bla');
}, true);

e.target.innerHTML is content of <script> tag.

woxxomMod
§
يوللانغان ۋاقتى: 2017-04-04
تەھرىرلەنگەن ۋاقتى: 2017-04-04

The OP uses Chrome which doesn't implement beforescriptexecute:

The beforescriptexecute/afterscriptexecute events have been removed from the specification (https://github.com/whatwg/html/pull/1103), and they will not be implemented in Chrome.

Because of this, uBlock origin extra extension fetches the page html via XHR, deletes the scripts, then rewrites the page using document.write (source code).

§
يوللانغان ۋاقتى: 2017-04-06

I use Opera it does not work signal ... but in firefox worked very well but it seems that the other scripts stop again thanks for answering me

جاۋاب قايتۇرۇش

جاۋاب قايتۇرۇش ئۈچۈن كىرىش.