1

After modifying a chrome extension‘js code and restart the chrome,the modified chrome extension becomes destroyed. Three months ago,i did the same thing to the same extension and it worked well.

This time i get a new computer and the lastest version chrome(46.0.2490.86 m),but once i modify the extension's source code it get destroyed.

Here is the source code and the extension. PS:i think it's because chrome refuse me to modify its origin extension code.

extension name:totop. extension function:Add a back to top button and go to bottom button on every page

i just modify "500" to "100" to accelerate its speed.

the main script.js:

 $("head").prepend("<style>._BackToTopPlus{width:35px;height:35px;border-radius:5px; position:fixed; right:10px; cursor:pointer; background-repeat:no-repeat; background-position:50% 50%; background-color:#000; opacity:.1;transition:opacity .2s ease-in-out;z-index:99999;}._BackToTopPlus:hover{opacity:.5}</style>");
var level=$(window).height()/2-50;
$("body").append("<div class='_BackToTopPlus' style='background-image:url(data:img/png;base64,R0lGODlhEgAUAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAASABQAAAImjI+py+IPo4xmWmRpyq5dFkzgoY3VY5KS9ykcKy6vnMEr3W417hQAOw==);top:"+(level-40)+"px;'></div>").append("<div class='_BackToTopPlus' style='background-image:url(data:img/png;base64,R0lGODlhEgAUAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAASABQAAAIqlB2peX27nINKNsoswnrTLmABKJKcJH5PGl3siKZdabZgWN2rzuPv/yoAADs=);top:"+(level+5)+"px;'></div>");
var jsq=0;
$("._BackToTopPlus").eq(0).click(function(){$("body").animate({scrollTop:0},500);}).mouseover(function(){
    jsq=setInterval(function(){
        $("body").scrollTop($("body").scrollTop()-1);
    },20);
}).mouseout(function(){clearInterval(jsq);jsq=null;});
$("._BackToTopPlus").eq(1).click(function(){$("body").animate({scrollTop:$(document).height()},500);}).mouseover(function(){
    jsq=setInterval(function(){
        $("body").scrollTop($("body").scrollTop()+1);
    },20);
}).mouseout(function(){clearInterval(jsq);jsq=null;});
Mr C
  • 41
  • 6
  • maybe related ? http://stackoverflow.com/questions/27657617/how-to-disable-google-chrome-extension-autoupdate – Hacketo Nov 17 '15 at 08:33
  • Try changing `chrome://flags/#extension-content-verification` flag to `bootstrap` although it will reduce the overall security of extensions so there's no guarantee Chrome will respect your setting, see https://crbug.com/443867 – wOxxOm Nov 18 '15 at 19:17
  • @wOxxOm, thank you very much. it is chrome default settings that cause my trouble. The path you proposed is ver nice. PS:me me da.(づ ̄3 ̄)づ╭❤~ – Mr C Nov 20 '15 at 02:56

1 Answers1

2

spend 1 years, i myself get the answer !

chrome browser will auto detect all its extension online to guarantee safety, so after editing one extension file, chrome browser will report error on the extension.

solution

  1. copy all extension files out, edit files what we need, delete other irrelevant files, modify manifest.json.
  2. start chrome develop mode
  3. load the extension

example

old extension files include

  • _locales
  • _metadata
  • jq.js
  • logo.png
  • manifest.json
  • script.js

new extension files

files we need is:

  • jq.js
  • logo.png
  • manifest.json
  • script.js

edit sript.js to get function we need. edit manifest.json, mine manifest.json like:

```

{
   "content_scripts": [ {
      "js": [ "jq.js", "script.js" ],
      "matches": [ "http://*/*", "https://*/*" ]
   } ],
   "icons": {
      "128": "logo.png"
   },
   "manifest_version": 2,
   "name": "ToTop",
   "version": "1.0.0.0"
}

```

Mr C
  • 41
  • 6